Beispiel #1
0
	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())
		})
	})

	Context("has webhooks", func() {
		BeforeEach(func() {
			es := []entity.Webhook{
				fake.WebhookEntity(),
				fake.WebhookEntity(),
			}
			repo.On("ListWebhooks").Return(es, nil)
			pres.On("List", es).Return(nil)
		})

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

	Context("erroring repo", func() {
		BeforeEach(func() {
			repo.On("ListWebhooks").Return(nil, errors.New("boom"))
		})
Beispiel #2
0
	"github.com/nullstyle/coinop/fake"
	"github.com/nullstyle/coinop/usecase"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("*postgres.Driver as WebrookRepository", func() {

	Describe("SaveWebhook", func() {
		var (
			subject *Driver
			input   entity.Webhook
			err     error
		)
		JustBeforeEach(func() {
			input = fake.WebhookEntity()
			subject = &Driver{DB: db}
			err = subject.SaveWebhook(&input)
		})

		Context("a new webhook", func() {
			It("sets an id", func() {
				Expect(err).ToNot(HaveOccurred())
				Expect(input.ID).To(BeAssignableToTypeOf(&usecase.RepoID{}))
				id := input.ID.(*usecase.RepoID)
				Expect(id.T).To(Equal("webhook"))
				Expect(id.V).To(Equal(int64(1)))
			})

			PIt("inserts a row")
		})