Documentation
¶
Index ¶
- Constants
- func GetRole(ctx context.Context) (string, bool)
- func GetUserID(ctx context.Context) (entity.UserID, bool)
- func IsAdmin(ctx context.Context) bool
- func SetRole(ctx context.Context, tok jwt.Token) context.Context
- func SetUserID(ctx context.Context, userID entity.UserID) context.Context
- type JWTer
- type Store
- type StoreMock
Constants ¶
View Source
const ( RoleKey = "role" UserNameKey = "user_name" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type JWTer ¶
func (*JWTer) GenerateToken ¶
type StoreMock ¶
type StoreMock struct { // LoadFunc mocks the Load method. LoadFunc func(ctx context.Context, key string) (entity.UserID, error) // SaveFunc mocks the Save method. SaveFunc func(ctx context.Context, key string, userID entity.UserID) error // contains filtered or unexported fields }
StoreMock is a mock implementation of Store.
func TestSomethingThatUsesStore(t *testing.T) { // make and configure a mocked Store mockedStore := &StoreMock{ LoadFunc: func(ctx context.Context, key string) (entity.UserID, error) { panic("mock out the Load method") }, SaveFunc: func(ctx context.Context, key string, userID entity.UserID) error { panic("mock out the Save method") }, } // use mockedStore in code that requires Store // and then make assertions. }
func (*StoreMock) LoadCalls ¶
LoadCalls gets all the calls that were made to Load. Check the length with:
len(mockedStore.LoadCalls())
Click to show internal directories.
Click to hide internal directories.