当前位置: 首页>>代码示例>>Golang>>正文


Golang mocks.NewErrorWriter函数代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/notifications/testing/mocks.NewErrorWriter函数的典型用法代码示例。如果您正苦于以下问题:Golang NewErrorWriter函数的具体用法?Golang NewErrorWriter怎么用?Golang NewErrorWriter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewErrorWriter函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

	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 {
			panic(err)
		}

		tokenHeader := map[string]interface{}{
			"alg": "FAST",
		}
		tokenClaims := map[string]interface{}{
			"user_id": "correct-user",
			"exp":     int64(3404281214),
开发者ID:dieucao,项目名称:notifications,代码行数:31,代码来源:get_preferences_handler_test.go

示例2:

)

var _ = Describe("Routes", func() {
	var muxer web.Muxer

	BeforeEach(func() {
		muxer = web.NewMuxer()
		notifications.Routes{
			RequestCounter:                   middleware.RequestCounter{},
			RequestLogging:                   middleware.RequestLogging{},
			DatabaseAllocator:                middleware.DatabaseAllocator{},
			NotificationsWriteAuthenticator:  middleware.Authenticator{Scopes: []string{"notifications.write"}},
			NotificationsManageAuthenticator: middleware.Authenticator{Scopes: []string{"notifications.manage"}},

			Registrar:            mocks.NewRegistrar(),
			ErrorWriter:          mocks.NewErrorWriter(),
			NotificationsFinder:  mocks.NewNotificationsFinder(),
			NotificationsUpdater: &mocks.NotificationUpdater{},
		}.Register(muxer)
	})

	Describe("/notifications", func() {
		It("routes PUT /notifications", func() {
			request, err := http.NewRequest("PUT", "/notifications", nil)
			Expect(err).NotTo(HaveOccurred())

			s := muxer.Match(request).(stack.Stack)
			Expect(s.Handler).To(BeAssignableToTypeOf(notifications.PutHandler{}))
			ExpectToContainMiddlewareStack(s.Middleware, middleware.RequestLogging{}, middleware.RequestCounter{}, middleware.Authenticator{}, middleware.DatabaseAllocator{})

			authenticator := s.Middleware[2].(middleware.Authenticator)
开发者ID:dieucao,项目名称:notifications,代码行数:31,代码来源:routes_test.go


注:本文中的github.com/cloudfoundry-incubator/notifications/testing/mocks.NewErrorWriter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。