"github.com/cloudfoundry-incubator/notifications/testing/mocks"
	"github.com/cloudfoundry-incubator/notifications/v2/collections"
	"github.com/cloudfoundry-incubator/notifications/v2/web/templates"
	"github.com/ryanmoran/stack"

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

var _ = Describe("DeleteHandler", func() {
	var (
		handler    templates.DeleteHandler
		writer     *httptest.ResponseRecorder
		request    *http.Request
		conn       *mocks.Connection
		database   *mocks.Database
		collection *mocks.TemplatesCollection
		context    stack.Context
	)

	BeforeEach(func() {
		writer = httptest.NewRecorder()

		context = stack.NewContext()

		conn = mocks.NewConnection()
		database = mocks.NewDatabase()
		database.ConnectionCall.Returns.Connection = conn
		context.Set("database", database)
		context.Set("client_id", "some-client-id")
import (
	"time"

	"github.com/cloudfoundry-incubator/notifications/postal"
	"github.com/cloudfoundry-incubator/notifications/testing/mocks"
	"github.com/cloudfoundry-incubator/notifications/v2/models"

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

var _ = Describe("Campaign Status Updater", func() {
	var (
		campaignStatusUpdater postal.CampaignStatusUpdater
		messagesRepo          *mocks.MessagesRepository
		campaignsRepo         *mocks.CampaignsRepository
		pollInterval          time.Duration
		database              *mocks.Database
	)

	BeforeEach(func() {
		database = mocks.NewDatabase()
		database.ConnectionCall.Returns.Connection = mocks.NewConnection()
		messagesRepo = mocks.NewMessagesRepository()
		campaignsRepo = mocks.NewCampaignsRepository()
		pollInterval = 1 * time.Millisecond

		campaignStatusUpdater = postal.NewCampaignStatusUpdater(database.Connection(),
			messagesRepo,
			campaignsRepo,
			pollInterval)
Example #3
0
	"github.com/cloudfoundry-incubator/notifications/gobble"
	"github.com/cloudfoundry-incubator/notifications/strategy"
	"github.com/cloudfoundry-incubator/notifications/testing/mocks"
	"github.com/cloudfoundry-incubator/notifications/v1/services"
	"github.com/cloudfoundry-incubator/notifications/v2/collections"
	"github.com/cloudfoundry-incubator/notifications/v2/queue"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Determiner", func() {
	var (
		determiner    strategy.Determiner
		userStrategy  *mocks.Strategy
		spaceStrategy *mocks.Strategy
		orgStrategy   *mocks.Strategy
		emailStrategy *mocks.Strategy
		database      *mocks.Database
	)
	BeforeEach(func() {
		userStrategy = mocks.NewStrategy()
		spaceStrategy = mocks.NewStrategy()
		orgStrategy = mocks.NewStrategy()
		emailStrategy = mocks.NewStrategy()
		database = mocks.NewDatabase()
		determiner = strategy.NewStrategyDeterminer(userStrategy, spaceStrategy, orgStrategy, emailStrategy)
	})

	Context("when dispatching to a user", func() {
		It("determines the strategy and calls it", func() {
			err := determiner.Determine(database.Connection(), "some-uaa-host", gobble.NewJob(queue.CampaignJob{
Example #4
0
package application_test

import (
	"github.com/cloudfoundry-incubator/notifications/application"
	"github.com/cloudfoundry-incubator/notifications/testing/mocks"

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

var _ = Describe("Migrator", func() {
	Describe("Migrate", func() {
		var (
			migrator       application.Migrator
			provider       *mocks.PersistenceProvider
			database       *mocks.Database
			gobbleDatabase *mocks.GobbleDatabase
			dbMigrator     *mocks.DatabaseMigrator
		)

		BeforeEach(func() {
			database = mocks.NewDatabase()
			gobbleDatabase = &mocks.GobbleDatabase{}
			provider = mocks.NewPersistenceProvider()
			provider.DatabaseCall.Returns.Database = database
			provider.GobbleDatabaseCall.Returns.Database = gobbleDatabase

			dbMigrator = mocks.NewDatabaseMigrator()
		})

		Context("when configured to run migrations", func() {
	"github.com/cloudfoundry-incubator/notifications/v2/collections"
	"github.com/cloudfoundry-incubator/notifications/v2/web/campaigns"
	"github.com/dgrijalva/jwt-go"
	"github.com/ryanmoran/stack"

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

var _ = Describe("CreateHandler", func() {
	var (
		handler             campaigns.CreateHandler
		campaignsCollection *mocks.CampaignsCollection
		context             stack.Context
		writer              *httptest.ResponseRecorder
		request             *http.Request
		database            *mocks.Database
		conn                *mocks.Connection
		clock               *mocks.Clock
		startTime           time.Time
	)

	BeforeEach(func() {
		tokenHeader := map[string]interface{}{
			"alg": "FAST",
		}
		tokenClaims := map[string]interface{}{
			"client_id": "some-uaa-client-id",
			"exp":       int64(3404281214),
			"scope":     []string{"notifications.write"},
		}