testutil

package
v2.0.0-ccit-pre2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthClientConfig

func AuthClientConfig(port uint16) *clientcredentials.Config

func AuthURL

func AuthURL(port uint16) string

func JWKSURL

func JWKSURL(port uint16) string

func NewInMemoryStorage

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 uint16, 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 uint16) string

Types

type ListRecvStreamerOf

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

func (ListRecvStreamerOf[MsgType]) CloseSend() error

func (ListRecvStreamerOf[MsgType]) Context

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

func (ListRecvStreamerOf[MsgType]) Header

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

func (*ListRecvStreamerOf[MsgType]) Recv

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

func (ListRecvStreamerOf[MsgType]) RecvMsg

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

func (ListRecvStreamerOf[MsgType]) SendMsg

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

func (ListRecvStreamerOf[MsgType]) Trailer

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

type StorageWithError

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

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

func (*StorageWithError) Count

func (s *StorageWithError) Count(_ any, _ ...any) (int64, error)

func (*StorageWithError) Create

func (s *StorageWithError) Create(_ any) error

func (*StorageWithError) Delete

func (s *StorageWithError) Delete(_ any, _ ...any) error

func (*StorageWithError) Get

func (s *StorageWithError) Get(_ any, _ ...any) error

func (*StorageWithError) List

func (s *StorageWithError) List(_ any, _ string, _ bool, _ int, _ int, _ ...any) error

func (*StorageWithError) Raw

func (s *StorageWithError) Raw(_ any, _ string, _ ...any) error

func (*StorageWithError) Save

func (s *StorageWithError) Save(_ any, _ ...any) error

func (*StorageWithError) Update

func (*StorageWithError) Update(_ any, _ ...any) error

Directories

Path Synopsis
Package assert contains helpful assertion helpers.
Package assert contains helpful assertion helpers.

Jump to

Keyboard shortcuts

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