Esempio n. 1
0
var _ = Describe("ProcessDelivery", func() {
	var (
		repo     *MockDeliveryRepository
		send     *MockDeliverySender
		delivery entity.Delivery
		err      error
	)

	BeforeEach(func() {
		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)
Esempio n. 2
0
var _ = Describe("ListWebhooks", func() {
	var (
		subject ListWebhooks
		repo    *MockWebhookRepository
		pres    *MockWebhookPresenter
		err     error
	)

	BeforeEach(func() {
		repo = &MockWebhookRepository{}
		pres = &MockWebhookPresenter{}
	})

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

	JustBeforeEach(func() {
		subject = ListWebhooks{repo, pres}
		err = subject.Exec()
	})

	Context("no webhooks", func() {
		BeforeEach(func() {
			repo.On("ListWebhooks").Return([]entity.Webhook{}, nil)
			pres.On("List", []entity.Webhook{}).Return(nil)
		})

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