Documentation ¶
Overview ¶
Package dbtest provides a way of starting a MongoDB or Postgres docker container prior to running the integration test suite. This packages manages the life cycle of the of this docker container it fires off the container, kill the container and remove its volume after the test suite is completed.
Here is an example on how to run these supported db containers:
import ( "github.com/akhettar/docker-db" ) func main() { // Starting Postgres container with an initialised schema file con1 := dbtest.StartPostgresContainerWithInitialisationScript("dbname", "schema.sql") fmt.Printf("mongo container with id running %s", con1.id) // Staring mongo container con2 := dbtest.StartMongoContainer() fmt.Printf("mongo container with id running %s", con2.id) }
Index ¶
Constants ¶
View Source
const ( PostgresUsername = "docker" PostgresPassword = "docker" IPAddressRegex = "(.*IPAddress\"\\: \")(.*)(\",)" VolumeRegex = "(volumes\\/)(.*)(\\/)" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container holding the docker container info
func StartPostgresContainer ¶
StartPostgresContainer starts a postgres container
func StartPostgresContainerWithInitialisationScript ¶
StartPostgresContainerWithInitialisationScript start a postgres container with an initialisation script.
Click to show internal directories.
Click to hide internal directories.