Documentation
¶
Index ¶
- Constants
- func RunCRDBForTesting(t testing.TB, crdbVersion string, opts ...testcontainers.ContainerCustomizer) *crdbTester
- type InitFunc
- type MySQLTesterOptions
- type RunningEngineForTest
- func RunDatastoreEngine(t testing.TB, engine string, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
- func RunMemoryForTesting(_ testing.TB) RunningEngineForTest
- func RunMySQLForTesting(t testing.TB, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
- func RunMySQLForTestingWithOptions(t testing.TB, options MySQLTesterOptions, ...) RunningEngineForTest
- func RunPostgresForTesting(t testing.TB, pgVersion string, enablePgbouncer bool, ...) RunningEngineForTest
- func RunPostgresForTestingWithCommitTimestamps(t testing.TB, withCommitTimestamps bool, pgVersion string, ...) RunningEngineForTest
- func RunSpannerForTesting(t testing.TB, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
Constants ¶
const ( // NOTE: this is used in this file but also duplicated in postgres.conf. PostgresTestMaxConnections = "3000" PgTestPass = "testpass" PgTestUser = "testuser" )
Variables ¶
This section is empty.
Functions ¶
func RunCRDBForTesting ¶ added in v1.7.0
func RunCRDBForTesting(t testing.TB, crdbVersion string, opts ...testcontainers.ContainerCustomizer) *crdbTester
RunCRDBForTesting returns a RunningEngineForTest for CRDB
Types ¶
type InitFunc ¶
InitFunc initializes a datastore instance from a uri that has been generated from a TestDatastoreBuilder
type MySQLTesterOptions ¶ added in v1.7.0
MySQLTesterOptions allows tweaking the behaviour of the builder for the MySQL datastore
type RunningEngineForTest ¶ added in v1.7.0
type RunningEngineForTest 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) datastore.Datastore
}
RunningEngineForTest represents an instance of a datastore engine running with its backing database/service, expressly for testing.
func RunDatastoreEngine ¶ added in v1.7.0
func RunDatastoreEngine(t testing.TB, engine string, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
RunDatastoreEngine 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 RunMemoryForTesting ¶ added in v1.7.0
func RunMemoryForTesting(_ testing.TB) RunningEngineForTest
RunMemoryForTesting returns a RunningEngineForTest for the in-memory driver.
func RunMySQLForTesting ¶ added in v1.7.0
func RunMySQLForTesting(t testing.TB, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
RunMySQLForTesting returns a RunningEngineForTest for the mysql driver backed by a MySQL instance with RunningEngineForTest options - no prefix is added, and datastore migration is run.
func RunMySQLForTestingWithOptions ¶ added in v1.7.0
func RunMySQLForTestingWithOptions(t testing.TB, options MySQLTesterOptions, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
RunMySQLForTestingWithOptions returns a RunningEngineForTest for the mysql driver backed by a MySQL instance, while allowing options to be forwarded
func RunPostgresForTesting ¶ added in v1.7.0
func RunPostgresForTesting(t testing.TB, pgVersion string, enablePgbouncer bool, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
RunPostgresForTesting returns a RunningEngineForTest for postgres
func RunPostgresForTestingWithCommitTimestamps ¶ added in v1.47.1
func RunPostgresForTestingWithCommitTimestamps(t testing.TB, withCommitTimestamps bool, pgVersion string, enablePgbouncer bool, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
func RunSpannerForTesting ¶ added in v1.7.0
func RunSpannerForTesting(t testing.TB, opts ...testcontainers.ContainerCustomizer) RunningEngineForTest
RunSpannerForTesting returns a RunningEngineForTest for spanner