more generic values

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-11 12:21:27 -07:00
parent e0efc237a4
commit 7b70f0feaa
2 changed files with 13 additions and 18 deletions

View File

@ -40,8 +40,6 @@ func marshalWriteToFile(myWriter *bufio.Writer, e *pb.Event) {
myWriter.Flush() myWriter.Flush()
log.Println("bufio.Write() tmp, err = ", tmp, err) log.Println("bufio.Write() tmp, err = ", tmp, err)
e.Id += 1
e.Name = "jcarrEvent21"
buf, err = proto.Marshal(e) buf, err = proto.Marshal(e)
tmp2, err := myWriter.Write(buf) tmp2, err := myWriter.Write(buf)
myWriter.Flush() myWriter.Flush()
@ -52,8 +50,6 @@ func TestWriteEvent() {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
e := pb.CreateSampleEvent() e := pb.CreateSampleEvent()
e.Id += 1
e.Name = "jcarrEvent2"
got := buf.String() got := buf.String()
log.Println(got) log.Println(got)

View File

@ -1,28 +1,27 @@
package witProtobuf package witProtobuf
import "log" import "log"
// import "bytes"
// import "os" //
// import "bufio" // This generates some sample data. It *should* match the .proto file
// import "io" //
// import "io/ioutil"
func CreateSampleEvent() *Event { func CreateSampleEvent() *Event {
// TODO: flush this out to do all the fields // TODO: flush this out to do all the fields
log.Println("CreateSampleEvent() is generating a example protobuf Event") log.Println("CreateSampleEvent() is generating a example protobuf Event")
e := &Event{ e := &Event{
Id: 1234, Id: 1234,
Name: "jcarrEvent1", Name: "Somekind of Event1",
Email: "jcarr@wit.com", Email: "test+protobuf@wit.com",
Results: []*Event_Response{ Comment: "this is a sample event",
{Name: "foobar", Type: Event_ADD}, Results: []*Event_Response{
{Name: "fooadd", Type: Event_ADD},
{Name: "foodelete", Type: Event_DELETE},
{Name: "foopoweron", Type: Event_POWERON},
}, },
} }
e.Id += 1
e.Name = "jcarrEvent2"
return e return e
} }
@ -36,7 +35,7 @@ func CreateSampleEvents(total int) []Event {
e := CreateSampleEvent() e := CreateSampleEvent()
e.Id += 1000 + int32(i) e.Id += 1000 + int32(i)
e.Name = "jcarrEvent2" e.Name = "Sample Event " + string(i)
all = append(all, *e) all = append(all, *e)
} }