예제 #1
0
		repo = &MockDeliveryRepository{}
		send = &MockDeliverySender{}
	})

	AfterEach(func() {
		test.VerifyMock(repo.Mock, send.Mock)
	})

	JustBeforeEach(func() {
		subject := &ProcessDelivery{repo, send}
		err = subject.Exec(context.Background(), delivery)
	})

	Context("working ports", func() {
		BeforeEach(func() {
			delivery = fake.DeliveryEntity()
			repo.
				On("StartDelivery", delivery).
				Return(int64(1), time.Now().Add(1*time.Second), nil)
			repo.On("MarkDeliverySuccess", int64(1), delivery).Return(nil)
			send.On("SendDelivery", delivery).Return(nil)
		})

		It("succeeds", func() {
			Expect(err).To(BeNil())
		})

	})

	Context("invalid delivery", func() {
		BeforeEach(func() {
예제 #2
0
			})
		})

	})

	Describe("SaveDeliveries", func() {
		var (
			cursor string
			ds     []entity.Delivery
			err    error
		)

		BeforeEach(func() {
			cursor = "123"
			ds = []entity.Delivery{
				fake.DeliveryEntity(),
				fake.DeliveryEntity(),
			}
			subject = Driver{DB: db}
		})

		JustBeforeEach(func() {
			err = subject.SaveDeliveries(cursor, ds)
		})

		It("saves the cursor", func() {
			saved, err := subject.LoadCursor()
			Expect(err).To(BeNil())
			Expect(saved).To(Equal(cursor))
		})