test

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// PassphraseVersion and Passphrase are registered with every test manager,
	// so that credentials can be encrypted
	PassphraseVersion = 1
	Passphrase        = "test passphrase"
)

Variables

This section is empty.

Functions

func Begin

func Begin(t *testing.T) (*credential.Manager, context.Context)

Begin returns the shared test manager and a per-test context, which is cancelled when the test ends.

func End

func End(t *testing.T)

End releases the per-test context created by Begin.

func IsolatedManager

func IsolatedManager(t *testing.T, opts ...credential.Opt) *credential.Manager

IsolatedManager returns a new manager on a new, empty database schema, so that a test can make assertions about every credential, which it cannot do with the shared manager as other tests also create credentials. The schema is dropped when the test ends.

func IsolatedSchema

func IsolatedSchema(t *testing.T) string

IsolatedSchema returns the name of a new, empty database schema, so that a test can create several managers on it with different options. The schema is dropped when the test ends.

func Main

func Main(m *testing.M, setup func(*credential.Manager) (func(), error), opts ...credential.Opt)

Main is the test main function for credential manager tests. It starts a PostgreSQL container, creates a manager on it, with the test passphrase, and runs the tests, which get the manager with Begin. The setup function, when it's set, is called with the manager before the tests run, and the teardown it returns after.

func Pool

func Pool() pg.PoolConn

Pool returns the shared test connection pool, such as for a connection of a test's own, which the manager can act on

func Schema

func Schema() string

Schema returns the database schema used by the shared test manager, for tests which need to refer to its tables directly

func SchemaManager

func SchemaManager(t *testing.T, schemaName string, opts ...credential.Opt) *credential.Manager

SchemaManager returns a new manager on the schema, with the test passphrase and the options. The manager isn't closed, as it shares the pool with the other managers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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