github.com/mantzas/incata@v0.3.0/appender_test.go (about) 1 package incata 2 3 import ( 4 "testing" 5 6 . "github.com/mantzas/incata/mocks" 7 . "github.com/mantzas/incata/model" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 "github.com/satori/go.uuid" 11 ) 12 13 var _ = Describe("Appender", func() { 14 15 It("create a new appender without setup", func() { 16 17 SetupAppender(nil) 18 appender, err := NewAppender() 19 Expect(appender).To(BeNil()) 20 Expect(err).To(MatchError("Writer is not set up!")) 21 }) 22 23 It("serialize with error", func() { 24 25 event := NewEvent(uuid.NewV4(), GetTestData(), "TEST", 1) 26 var data = make([]Event, 0) 27 wr := NewMemoryWriter(data) 28 SetupAppender(wr) 29 ar, err := NewAppender() 30 err = ar.Append(*event) 31 Expect(err).NotTo(HaveOccurred()) 32 }) 33 34 }) 35 36 func BenchmarkAppender(b *testing.B) { 37 38 var data = make([]Event, 0) 39 wr := NewMemoryWriter(data) 40 41 SetupAppender(wr) 42 43 appender, _ := NewAppender() 44 45 event := NewEvent(uuid.NewV4(), GetTestData(), "TEST", 1) 46 47 for n := 0; n < b.N; n++ { 48 appender.Append(*event) 49 } 50 }