コード例 #1
0
	BeforeEach(func() {
		database := models.NewDatabase(sqlDB, models.Config{})
		helpers.TruncateTables(db.NewDatabase(sqlDB, db.Config{}))
		conn = database.Connection().(*db.Connection)
		conn.AddTableWithName(models.Message{}, "messages")
		clock = mocks.NewClock()

		repo = models.NewMessagesRepository(clock)
	})

	Describe("CountByStatus", func() {
		BeforeEach(func() {
			err := conn.Insert(&models.Message{
				ID:         "message-id-123",
				CampaignID: "some-campaign-id",
				Status:     postal.StatusDelivered,
			})
			Expect(err).NotTo(HaveOccurred())

			err = conn.Insert(&models.Message{
				ID:         "message-id-1234",
				CampaignID: "some-campaign-id",
				Status:     postal.StatusFailed,
			})
			Expect(err).NotTo(HaveOccurred())

			err = conn.Insert(&models.Message{
				ID:         "message-id-456",
				CampaignID: "some-campaign-id",
				Status:     postal.StatusDelivered,