Skip to content

Commit

Permalink
fix: use valid MSSQL image
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Sep 19, 2024
1 parent 4a11fc6 commit 4dbd183
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
7 changes: 1 addition & 6 deletions modules/mssql/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ import (
)

func ExampleRun() {
// TODO: restore once #2785 is fixed
if true {
fmt.Println("true")
return
}
// runMSSQLServerContainer {
ctx := context.Background()

password := "SuperStrong@Passw0rd"

mssqlContainer, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-RTM-GDR1-ubuntu-20.04",
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
mssql.WithAcceptEULA(),
mssql.WithPassword(password),
)
Expand Down
2 changes: 1 addition & 1 deletion modules/mssql/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func WithPassword(password string) testcontainers.CustomizeRequestOption {
// Deprecated: use Run instead
// RunContainer creates an instance of the MSSQLServer container type
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*MSSQLServerContainer, error) {
return Run(ctx, "mcr.microsoft.com/mssql/server:2022-CU10-ubuntu-22.04", opts...)
return Run(ctx, "mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04", opts...)
}

// Run creates an instance of the MSSQLServer container type
Expand Down
38 changes: 5 additions & 33 deletions modules/mssql/mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import (
)

func TestMSSQLServer(t *testing.T) {
t.Skip("broken see #2785")
ctx := context.Background()

ctr, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-CU10-ubuntu-22.04",
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
mssql.WithAcceptEULA(),
)
testcontainers.CleanupContainer(t, ctr)
Expand All @@ -44,11 +43,10 @@ func TestMSSQLServer(t *testing.T) {
}

func TestMSSQLServerWithMissingEulaOption(t *testing.T) {
t.Skip("broken see #2785")
ctx := context.Background()

ctr, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-CU10-ubuntu-22.04",
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
testcontainers.WithWaitStrategy(
wait.ForLog("The SQL Server End-User License Agreement (EULA) must be accepted")),
)
Expand All @@ -64,11 +62,10 @@ func TestMSSQLServerWithMissingEulaOption(t *testing.T) {
}

func TestMSSQLServerWithConnectionStringParameters(t *testing.T) {
t.Skip("broken see #2785")
ctx := context.Background()

ctr, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-CU10-ubuntu-22.04",
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
mssql.WithAcceptEULA(),
)
testcontainers.CleanupContainer(t, ctr)
Expand All @@ -95,11 +92,10 @@ func TestMSSQLServerWithConnectionStringParameters(t *testing.T) {
}

func TestMSSQLServerWithCustomStrongPassword(t *testing.T) {
t.Skip("broken see #2785")
ctx := context.Background()

ctr, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-CU10-ubuntu-22.04",
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
mssql.WithAcceptEULA(),
mssql.WithPassword("Strong@Passw0rd"),
)
Expand All @@ -120,11 +116,10 @@ func TestMSSQLServerWithCustomStrongPassword(t *testing.T) {

// tests that a weak password is not accepted by the container due to Microsoft's password strength policy
func TestMSSQLServerWithInvalidPassword(t *testing.T) {
t.Skip("broken see #2785")
ctx := context.Background()

ctr, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-CU10-ubuntu-22.04",
"mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04",
testcontainers.WithWaitStrategy(
wait.ForLog("Password validation failed")),
mssql.WithAcceptEULA(),
Expand All @@ -133,26 +128,3 @@ func TestMSSQLServerWithInvalidPassword(t *testing.T) {
testcontainers.CleanupContainer(t, ctr)
require.NoError(t, err)
}

func TestMSSQLServerWithAlternativeImage(t *testing.T) {
t.Skip("broken see #2785")
ctx := context.Background()

ctr, err := mssql.Run(ctx,
"mcr.microsoft.com/mssql/server:2022-RTM-GDR1-ubuntu-20.04",
mssql.WithAcceptEULA(),
)
testcontainers.CleanupContainer(t, ctr)
require.NoError(t, err)

// perform assertions
connectionString, err := ctr.ConnectionString(ctx)
require.NoError(t, err)

db, err := sql.Open("sqlserver", connectionString)
require.NoError(t, err)
defer db.Close()

err = db.Ping()
require.NoError(t, err)
}

0 comments on commit 4dbd183

Please sign in to comment.