コード例 #1
0
	"github.com/cloudfoundry-incubator/notifications/v1/web/webutil"
	"github.com/dgrijalva/jwt-go"
	"github.com/ryanmoran/stack"

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

var _ = Describe("GetPreferencesHandler", func() {
	var (
		handler           preferences.GetPreferencesHandler
		writer            *httptest.ResponseRecorder
		request           *http.Request
		preferencesFinder *mocks.PreferencesFinder
		errorWriter       *mocks.ErrorWriter
		builder           services.PreferencesBuilder
		context           stack.Context
		database          *mocks.Database

		TRUE  = true
		FALSE = false
	)

	BeforeEach(func() {
		errorWriter = mocks.NewErrorWriter()

		writer = httptest.NewRecorder()
		body, err := json.Marshal(map[string]string{
			"I think this request is empty": "maybe",
		})
		if err != nil {
コード例 #2
0
package services_test

import (
	"github.com/cloudfoundry-incubator/notifications/v1/models"
	"github.com/cloudfoundry-incubator/notifications/v1/services"

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

var _ = Describe("NotificationsPreferences", func() {
	var builder services.PreferencesBuilder
	var TRUE = true
	var FALSE = false

	Describe("Add", func() {
		BeforeEach(func() {
			builder = services.NewPreferencesBuilder()
		})

		It("adds new preferences", func() {
			builder.Add(models.Preference{
				ClientID:          "clientID",
				KindID:            "kindID",
				Email:             true,
				KindDescription:   "kind description",
				SourceDescription: "client description",
			})

			node := builder.Clients["clientID"]["kindID"]
			Expect(node).To(Equal(services.Kind{