Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAcceptEULA ¶
func WithAcceptEULA() testcontainers.CustomizeRequestOption
WithAcceptEULA sets the ACCEPT_EULA environment variable to "Y"
func WithInitSQL ¶ added in v0.36.0
WithInitSQL adds SQL scripts to be executed after the container is ready. The scripts are executed in the order they are provided using sqlcmd tool.
func WithPassword ¶
func WithPassword(password string) testcontainers.CustomizeRequestOption
WithPassword sets the MSSQL_SA_PASSWORD environment variable to the provided password
Types ¶
type MSSQLServerContainer ¶
type MSSQLServerContainer struct {
testcontainers.Container
// contains filtered or unexported fields
}
MSSQLServerContainer represents the MSSQLServer container type used in the module
func Run ¶ added in v0.32.0
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*MSSQLServerContainer, error)
Run creates an instance of the MSSQLServer container type
Example ¶
// runMSSQLServerContainer {
ctx := context.Background()
password := "SuperStrong@Passw0rd"
mssqlContainer, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
mssql.WithAcceptEULA(),
mssql.WithPassword(password),
)
defer func() {
if err := testcontainers.TerminateContainer(mssqlContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := mssqlContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
Output: true
func RunContainer
deprecated
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*MSSQLServerContainer, error)
Deprecated: use Run instead RunContainer creates an instance of the MSSQLServer container type
func (*MSSQLServerContainer) ConnectionString ¶
func (c *MSSQLServerContainer) ConnectionString(ctx context.Context, args ...string) (string, error)
ConnectionString returns the connection string for the MSSQLServer container
func (*MSSQLServerContainer) Password ¶ added in v0.36.0
func (c *MSSQLServerContainer) Password() string
Password returns the password for the MSSQLServer container