storage

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryTester

func NewMemoryTester[T any]() *memoryTest[T]

func NewPostgresTester

func NewPostgresTester[T any]() *postgresTester[T]

Types

type DatastoreTestEngine

type DatastoreTestEngine[T any] struct{}

func NewDatastoreTestEngine

func NewDatastoreTestEngine[T any]() *DatastoreTestEngine[T]

func (*DatastoreTestEngine[T]) RunDatastoreTestEngine

func (d *DatastoreTestEngine[T]) RunDatastoreTestEngine(t testing.TB, engine string) RunningEngineForTest[T]

RunDatastoreTestEngine starts the backing database or service necessary for the given engine for testing and sets the defaults for that database or service. Note that this does *NOT* create the logical database nor call migrate; callers can do so via NewDatabase and NewDatastore respectively. Note also that the backing database or service will be shutdown automatically via the Cleanup of the testing object.

func (*DatastoreTestEngine[T]) RunDatastoreTestEngineWithBridge

func (d *DatastoreTestEngine[T]) RunDatastoreTestEngineWithBridge(t testing.TB, engine, bridgeNetworkName string) RunningEngineForTest[T]

RunDatastoreTestEngineWithBridge runs a datastore engine on a specific bridge. If a bridge is specified, then the hostnames returned by the engines are those to be called from another container on the bridge.

type InitFunc

type InitFunc[T any] func(engine, uri string) T

InitFunc initializes a datastore instance from a uri that has been generated from a TestStorageBuilder

type RunningEngineForTest

type RunningEngineForTest[T any] interface {

	// NewDatabase returns the connection string to a new initialized logical database,
	// but one that is not migrated.
	NewDatabase(t testing.TB) string

	// NewDatastore returns a new logical datastore initialized with the
	// initFunc. For example, the sql based stores will create a new logical
	// database in the database instance, migrate it and provide the URI for it
	// to initFunc
	NewDatastore(t testing.TB, initFunc InitFunc[T]) T
}

RunningEngineForTest represents an instance of a database engine running with its backing database/service, expressly for testing.

func RunMemoryForTesting

func RunMemoryForTesting[T any](t testing.TB) RunningEngineForTest[T]

RunMemoryForTesting returns a RunningEngineForTest for the in-memory driver.

func RunOpenFGADatastoreTestEngine

func RunOpenFGADatastoreTestEngine(t testing.TB, engine string) RunningEngineForTest[storage.OpenFGADatastore]

RunOpenFGADatastoreTestEngine runs a datastore test engine specifically for the OpenFGADatastore storage interface.

Jump to

Keyboard shortcuts

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