witProtobuf/sampleData.go

45 lines
941 B
Go
Raw Normal View History

package witProtobuf
import "log"
//
// This generates some sample data. It *should* match the .proto file
//
func CreateSampleEvent() *Event {
// TODO: flush this out to do all the fields
log.Println("CreateSampleEvent() is generating a example protobuf Event")
e := &Event{
Id: 1234,
Name: "Somekind of Event1",
Email: "test+protobuf@wit.com",
Comment: "this is a sample event",
Results: []*Event_Response{
{Name: "fooadd", Type: Event_ADD},
{Name: "foodelete", Type: Event_DELETE},
{Name: "foopoweron", Type: Event_POWERON},
},
}
return e
}
func CreateSampleEvents(total int) []Event {
// TODO: flush this out to do all the fields
log.Println("CreateSampleEvent() is generating %d protobuf Events", total)
var all []Event
for i := 0; i < total; i++ {
e := CreateSampleEvent()
e.Id += 1000 + int32(i)
e.Name = "Sample Event " + string(i)
all = append(all, *e)
}
return all
}