Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add module to support Microsoft SQL Server #1969

Merged
merged 16 commits into from
Dec 6, 2023
54 changes: 54 additions & 0 deletions modules/mssql/mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,60 @@ func TestMSSQLServer(t *testing.T) {
}
}

func TestMSSQLServerWithInvalidEulaOption(t *testing.T) {
ctx := context.Background()

container, err := RunContainer(ctx)
testcontainers.WithWaitStrategy(
wait.ForLog("The SQL Server End-User License Agreement (EULA) must be accepted"))

if container == nil && err != nil {
t.Log("Success: Confirmed proper handling of missing EULA, so container is nil.")
} else {
t.Fatalf("Expected a log to confirm missing EULA but got error: %s", err)
}
}

// Microsoft requires that the EULA be accepted in order to run the container
// but this can be done by passing ANY value to the ACCEPT_EULA environment variable
// however, passing "Y" as the value is standard convention as seen throughout this module.
mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
// This will test that the container can, in fact, be run with an alternative EULA option value.
func TestMSSQLServerWithValidAlternateEula(t *testing.T) {
ctx := context.Background()

container, err := RunContainer(ctx,
WithAcceptEULA("alternativeValue"),
)

if err != nil {
t.Fatal(err)
}

// Clean up the container after the test is complete
t.Cleanup(func() {
if err := container.Terminate(ctx); err != nil {
t.Fatalf("failed to terminate container: %s", err)
}
})

// perform assertions
connectionString, err := container.ConnectionString(ctx)

if err != nil {
t.Fatal(err)
}

db, err := sql.Open("sqlserver", connectionString)
if err != nil {
t.Fatal(err)
}
defer db.Close()

if err = db.Ping(); err != nil {
t.Errorf("error pinging db: %+v\n", err)
}
}

func TestMSSQLServerWithConnectionStringParameters(t *testing.T) {
ctx := context.Background()

Expand Down