Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MySqlTestContainer ¶
type MySqlTestContainer struct {
// contains filtered or unexported fields
}
func Create ¶
func Create(name string) (*MySqlTestContainer, error)
Create creates a container containing MySQL in Docker & returns the connection info along with the created database.
Example ¶
package main import ( "github.com/andylongstaffe/go-mysql-test-container/mysqltestcontainer" "github.com/containerd/containerd/log" ) func main() { mySql, _ := mysqltestcontainer.Create("test") db := mySql.GetDb() err := db.Ping() if err != nil { log.L.Errorln(err.Error()) } }
Output:
func CreateWithConfig ¶
func CreateWithConfig(cfg Config) (*MySqlTestContainer, error)
CreateWithConfig creates a container containing MySQL in Docker & returns the connection info along with the created database. You are responsible for calling GetContainer().Terminate() to tear down the container since the reaper for testcontainers has been turned off
func CreateWithMigrate ¶
func CreateWithMigrate(databaseName string, migrationURL string) (*MySqlTestContainer, error)
func (*MySqlTestContainer) GetContainer ¶
func (m *MySqlTestContainer) GetContainer() testcontainers.Container
func (*MySqlTestContainer) GetDb ¶
func (m *MySqlTestContainer) GetDb() *sql.DB
func (*MySqlTestContainer) GetDbInfo ¶
func (m *MySqlTestContainer) GetDbInfo() *DbInfo
Click to show internal directories.
Click to hide internal directories.