testutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServiceID is used for testing (unit and integration tests)
	DefaultServiceID = "00000000-0000-0000-0000-000000000000"
)

Variables

This section is empty.

Functions

func NewInMemoryStorage

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

NewInMemoryStorage uses the Clouditor 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 NewInMemoryStorageWithListError added in v0.2.0

func NewInMemoryStorageWithListError(t *testing.T, listErrorMsg string, funcs ...func(s persistence.Storage)) persistence.Storage

NewInMemoryStorageWithListError uses the Clouditor in-memory 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 NewInMemoryStorageWithSaveError added in v0.2.0

func NewInMemoryStorageWithSaveError(t *testing.T, saveErrorMsg string, funcs ...func(s persistence.Storage)) persistence.Storage

NewInMemoryStorageWithSaveError uses the Clouditor in-memory 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.

Types

type StorageWithError

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

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

func (*StorageWithError) Create

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

func (*StorageWithError) Delete

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

func (*StorageWithError) Get

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

func (*StorageWithError) List

func (s *StorageWithError) List(_ interface{}, _ string, _ bool, _ int, _ int, _ ...interface{}) error

func (*StorageWithError) Save

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

func (*StorageWithError) Update

func (*StorageWithError) Update(_ interface{}, _ interface{}, _ ...interface{}) error

type StorageWithListError added in v0.2.0

type StorageWithListError struct {
	persistence.Storage

	ListErr error
}

StorageWithListError can be used to introduce various errors (without Create) in a storage operation during unit testing.

func (*StorageWithListError) List added in v0.2.0

func (s *StorageWithListError) List(_ interface{}, _ string, _ bool, _ int, _ int, _ ...interface{}) error

type StorageWithSaveError added in v0.2.0

type StorageWithSaveError struct {
	persistence.Storage

	SaveErr error
}

StorageWithSaveError can be used to introduce `save` error in a storage operation during unit testing.

func (*StorageWithSaveError) Save added in v0.2.0

func (s *StorageWithSaveError) Save(_ interface{}, _ ...interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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