import (
	"github.com/cloudfoundry-incubator/notifications/db"
	"github.com/cloudfoundry-incubator/notifications/testing/helpers"
	"github.com/cloudfoundry-incubator/notifications/v1/models"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("UnsubscribesRepo", func() {
	var repo models.UnsubscribesRepo
	var conn *db.Connection

	BeforeEach(func() {
		repo = models.NewUnsubscribesRepo()

		database := db.NewDatabase(sqlDB, db.Config{})
		helpers.TruncateTables(database)
		conn = database.Connection().(*db.Connection)
	})

	Describe("Get/Set", func() {
		It("returns false for unsubscribes that have not been set", func() {
			isUnsubscribed, err := repo.Get(conn, "user-id", "client-id", "kind-id")
			Expect(err).NotTo(HaveOccurred())
			Expect(isUnsubscribed).To(BeFalse())
		})

		It("returns true for unsubscribes that have been set", func() {
			err := repo.Set(conn, "user-id", "client-id", "kind-id", true)
Beispiel #2
0
func (m *Mother) UnsubscribesRepo() v1models.UnsubscribesRepo {
	return v1models.NewUnsubscribesRepo()
}