github.com/blend/go-sdk@v1.20220411.3/web/ctx_option_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package web 9 10 import ( 11 "net/http" 12 "testing" 13 14 "github.com/blend/go-sdk/assert" 15 ) 16 17 func TestCtxOption(t *testing.T) { 18 assert := assert.New(t) 19 20 var ctx Ctx 21 assert.Nil(ctx.App) 22 OptCtxApp(&App{})(&ctx) 23 assert.NotNil(ctx.App) 24 25 assert.Empty(ctx.Auth.CookieDefaults.Name) 26 OptCtxAuth(AuthManager{CookieDefaults: http.Cookie{Name: "foo"}})(&ctx) 27 assert.Equal("foo", ctx.Auth.CookieDefaults.Name) 28 29 assert.Nil(ctx.DefaultProvider) 30 OptCtxDefaultProvider(JSON)(&ctx) 31 assert.NotNil(ctx.DefaultProvider) 32 33 assert.Nil(ctx.Views) 34 OptCtxViews(&ViewCache{})(&ctx) 35 assert.NotNil(ctx.Views) 36 37 assert.Nil(ctx.State) 38 OptCtxState(&SyncState{})(&ctx) 39 assert.NotNil(ctx.State) 40 41 assert.Nil(ctx.Session) 42 OptCtxSession(&Session{})(&ctx) 43 assert.NotNil(ctx.Session) 44 45 assert.Nil(ctx.Route) 46 OptCtxRoute(&Route{})(&ctx) 47 assert.NotNil(ctx.Route) 48 49 assert.Nil(ctx.RouteParams) 50 OptCtxRouteParams(RouteParameters{})(&ctx) 51 assert.NotNil(ctx.RouteParams) 52 53 assert.Nil(ctx.Tracer) 54 OptCtxTracer(&mockTracer{})(&ctx) 55 assert.NotNil(ctx.Tracer) 56 }