Documentation ¶
Overview ¶
Package spantest implements: * start/stop the Cloud Spanner Emulator, * creation/removal of a temporary gcloud config, * creation of a temporary Spanner instance, * creation/destruction of a temporary Spanner database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeDBName ¶
SanitizeDBName tranforms name to a valid one. If name is already valid, returns it without changes.
Types ¶
type Emulator ¶
type Emulator struct {
// contains filtered or unexported fields
}
Emulator is for starting and stopping a Cloud Spanner Emulator process. TODO(crbug.com/1066993): Make Emulator an interfact with two implementations (*nativeEmulator and *dockerEmulator).
func StartEmulator ¶
StartEmulator starts a Cloud Spanner Emulator instance.
func (*Emulator) NewInstance ¶
NewInstance creates a temporary instance using Cloud Spanner Emulator.
type TempDB ¶
type TempDB struct { Name string // contains filtered or unexported fields }
TempDB is a temporary Spanner database.
func NewTempDB ¶
NewTempDB creates a temporary database with a random name. The caller is responsible for calling Drop on the returned TempDB to cleanup resources after usage. Unless it uses Cloud Spanner Emulator, then the database will be dropped when emulator stops.
type TempDBConfig ¶
type TempDBConfig struct { // InstanceName is the name of Spannner instance where to create the // temporary database. // Format: projects/{project}/instances/{instance}. // Defaults to chromeinfra.TestSpannerInstance. InstanceName string // InitScriptPath is a path to a DDL script to initialize the database. // // In lieu of a proper DDL parser, it is parsed using regexes. // Therefore the script MUST: // - Use `#“ and/or `--“ for comments. No block comments. // - Separate DDL statements with `;\n`. // // If empty, the database is created with no tables. InitScriptPath string }
TempDBConfig specifies how to create a temporary database.