testutil

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestAuthUser     = "clouditor"
	TestAuthPassword = "clouditor"

	TestAuthClientID     = "client"
	TestAuthClientSecret = "secret"
)

Variables

This section is empty.

Functions

func AuthClientConfig

func AuthClientConfig(port int) *clientcredentials.Config

func AuthURL

func AuthURL(port int) string

func JWKSURL

func JWKSURL(port int) string

func NewInMemoryStorage added in v1.4.5

func NewInMemoryStorage(t *testing.T, funcs ...func(s persistence.Storage)) (s persistence.Storage)

NewInMemoryStorage uses the inmemory package to create a new in-memory storage that can be used for unit testing. The funcs varargs can be used to immediately execute storage operations on it.

func StartAuthenticationServer

func StartAuthenticationServer() (srv *oauth2.AuthorizationServer, port int, err error)

StartAuthenticationServer starts an authentication server on a random port with users and clients specified in the TestAuthUser and TestAuthClientID constants.

func TokenURL

func TokenURL(port int) string

Types

type ListRecvStreamerOf added in v1.4.5

type ListRecvStreamerOf[MsgType proto.Message] struct {
	Messages []MsgType
}

ListRecvStreamerOf implements a grpc.ClientStream that mocks the reception of a list of messages and then EOFs.

func (ListRecvStreamerOf[MsgType]) CloseSend added in v1.4.5

func (ListRecvStreamerOf[MsgType]) CloseSend() error

func (ListRecvStreamerOf[MsgType]) Context added in v1.4.5

func (ListRecvStreamerOf[MsgType]) Context() context.Context

func (ListRecvStreamerOf[MsgType]) Header added in v1.4.5

func (ListRecvStreamerOf[MsgType]) Header() (metadata.MD, error)

func (*ListRecvStreamerOf[MsgType]) Recv added in v1.4.5

func (l *ListRecvStreamerOf[MsgType]) Recv() (req MsgType, err error)

func (ListRecvStreamerOf[MsgType]) RecvMsg added in v1.4.5

func (ListRecvStreamerOf[MsgType]) RecvMsg(_ interface{}) error

func (ListRecvStreamerOf[MsgType]) SendMsg added in v1.4.5

func (ListRecvStreamerOf[MsgType]) SendMsg(_ interface{}) error

func (ListRecvStreamerOf[MsgType]) Trailer added in v1.4.5

func (ListRecvStreamerOf[MsgType]) Trailer() metadata.MD

type StorageWithError added in v1.4.5

type StorageWithError struct {
	CreateErr error
	SaveErr   error
	UpdateErr error
	GetErr    error
	ListErr   error
	CountErr  error
	DeleteErr error
}

StorageWithError can be used to introduce various errors in a storage operation during unit testing.

func (*StorageWithError) Count added in v1.4.5

func (s *StorageWithError) Count(r interface{}, conds ...interface{}) (int64, error)

func (*StorageWithError) Create added in v1.4.5

func (s *StorageWithError) Create(r interface{}) error

func (*StorageWithError) Delete added in v1.4.5

func (s *StorageWithError) Delete(r interface{}, conds ...interface{}) error

func (*StorageWithError) Get added in v1.4.5

func (s *StorageWithError) Get(r interface{}, conds ...interface{}) error

func (*StorageWithError) List added in v1.4.5

func (s *StorageWithError) List(r interface{}, conds ...interface{}) error

func (*StorageWithError) Save added in v1.4.5

func (s *StorageWithError) Save(r interface{}, conds ...interface{}) error

func (*StorageWithError) Update added in v1.4.5

func (*StorageWithError) Update(r interface{}, query interface{}, args ...interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL