Documentation ¶
Overview ¶
Implements tooling to setup a Spanner database configured for running integration tests against.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSpannerInstance ¶
func NewSpannerInstance(ctx context.Context, projectID, instanceID string, opts ...option.ClientOption) error
NewSpannerInstance creates a spanner instance. This is intended for use with a spanner emulator.
func PostgresConnStr ¶ added in v0.1.2
Types ¶
type PostgresContainer ¶ added in v0.1.2
type PostgresContainer struct { testcontainers.Container // contains filtered or unexported fields }
PostgresContainer represents a docker container running a postgres instance.
func NewPostgresContainer ¶ added in v0.1.2
func NewPostgresContainer(ctx context.Context, imageVersion string) (*PostgresContainer, error)
NewPostgresContainer returns a new PostgresContainer ready to use with postgres.
func (*PostgresContainer) Close ¶ added in v0.1.2
func (pc *PostgresContainer) Close()
Close closes all connections to the postgres instance
func (*PostgresContainer) CreateDatabase ¶ added in v0.1.2
func (pc *PostgresContainer) CreateDatabase(ctx context.Context, dbName string) (*PostgresDatabase, error)
CreateDatabase creates a new database with the given name and returns a connection to it.
type PostgresDatabase ¶ added in v0.1.2
PostgresDatabase represents a postgres database created and ready for migrations
func NewPostgresDatabase ¶ added in v0.1.2
func NewPostgresDatabase(ctx context.Context, database, schema, connStr string) (*PostgresDatabase, error)
NewPostgresDatabase represents a new postgres database
func (*PostgresDatabase) Close ¶ added in v0.1.2
func (db *PostgresDatabase) Close()
Close closes the database connection
func (*PostgresDatabase) MigrateDown ¶ added in v0.1.2
func (db *PostgresDatabase) MigrateDown(sourceURL string) error
MigrateDown will migrate all the way down
func (*PostgresDatabase) MigrateUp ¶ added in v0.1.2
func (db *PostgresDatabase) MigrateUp(sourceURL ...string) error
MigrateUp will migrate all the way up, applying all up migrations from all sourceURL's
func (*PostgresDatabase) Schema ¶ added in v0.1.2
func (db *PostgresDatabase) Schema() string
Schema returns the default schema
type SpannerContainer ¶
type SpannerContainer struct { testcontainers.Container // contains filtered or unexported fields }
SpannerContainer represents a docker container running a spanner instance.
func NewSpannerContainer ¶
func NewSpannerContainer(ctx context.Context, imageVersion string) (*SpannerContainer, error)
NewSpannerContainer returns a initialized SpannerContainer ready to run to create databases for unit tests
func (*SpannerContainer) Close ¶
func (sc *SpannerContainer) Close() error
Close cleans up open resouces
func (*SpannerContainer) CreateDatabase ¶ added in v0.2.0
CreateDatabase creates a database with dbName. Each test should create their own database for testing
type SpannerDB ¶
SpannerDB represents a database created and ready for migrations
func NewSpannerDatabase ¶
func NewSpannerDatabase(ctx context.Context, projectID, instanceID, dbName string, opts ...option.ClientOption) (*SpannerDB, error)
NewSpannerDatabase will create a spanner database
func (*SpannerDB) MigrateDown ¶
MigrateDown will migrate all the way down