github.com/mantzas/incata@v0.3.0/retriever_test.go (about) 1 package incata 2 3 import ( 4 . "github.com/mantzas/incata/mocks" 5 . "github.com/mantzas/incata/model" 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 "github.com/satori/go.uuid" 9 ) 10 11 var _ = Describe("Retriever", func() { 12 13 It("create a new appender without setup", func() { 14 15 SetupRetriever(nil) 16 retriever, err := NewRetriever() 17 Expect(retriever).To(BeNil()) 18 Expect(err).To(MatchError("Reader is not set up!")) 19 }) 20 21 It("retrieve data succeeds", func() { 22 23 var sourceID = uuid.NewV4() 24 var data = make([]Event, 0) 25 26 data = append(data, *NewEvent(uuid.NewV4(), GetTestData(), "TEST", 1)) 27 data = append(data, *NewEvent(sourceID, GetTestData(), "TEST", 1)) 28 data = append(data, *NewEvent(uuid.NewV4(), GetTestData(), "TEST", 1)) 29 data = append(data, *NewEvent(sourceID, GetTestData(), "TEST", 1)) 30 data = append(data, *NewEvent(uuid.NewV4(), GetTestData(), "TEST", 1)) 31 32 rd := NewMemoryReader(data) 33 34 SetupRetriever(rd) 35 36 r, err := NewRetriever() 37 Expect(err).NotTo(HaveOccurred()) 38 39 events, err := r.Retrieve(sourceID) 40 Expect(err).NotTo(HaveOccurred()) 41 42 Expect(len(events)).To(Equal(2)) 43 }) 44 })