|
| 1 | +package mssql |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + _ "github.com/microsoft/go-mssqldb" |
| 7 | + "github.com/stretchr/testify/require" |
| 8 | +) |
| 9 | + |
| 10 | +// tests that the correct path to the sqlcmd executable is returned based on the image tag |
| 11 | +func TestGetSQLCmdPath(t *testing.T) { |
| 12 | + assertSQLCmdPath := func(t *testing.T, imageTag, expectedPath string) { |
| 13 | + t.Helper() |
| 14 | + got := getSQLCmdPath(imageTag) |
| 15 | + require.Equal(t, expectedPath, got) |
| 16 | + } |
| 17 | + |
| 18 | + t.Run("2019-CU14/old-version", func(t *testing.T) { |
| 19 | + t.Parallel() |
| 20 | + assertSQLCmdPath(t, "mcr.microsoft.com/mssql/server:2019-CU14-ubuntu-20.04", "/opt/mssql-tools/bin/sqlcmd") |
| 21 | + }) |
| 22 | + |
| 23 | + t.Run("2022-latest/new-version", func(t *testing.T) { |
| 24 | + t.Parallel() |
| 25 | + assertSQLCmdPath(t, "mcr.microsoft.com/mssql/server:2022-latest", "/opt/mssql-tools18/bin/sqlcmd") |
| 26 | + }) |
| 27 | + |
| 28 | + t.Run("2019-latest/old-version", func(t *testing.T) { |
| 29 | + t.Parallel() |
| 30 | + assertSQLCmdPath(t, "mcr.microsoft.com/mssql/server:2019-latest", "/opt/mssql-tools/bin/sqlcmd") |
| 31 | + }) |
| 32 | + |
| 33 | + t.Run("2022-CU14/new-version", func(t *testing.T) { |
| 34 | + t.Parallel() |
| 35 | + assertSQLCmdPath(t, "mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04", "/opt/mssql-tools18/bin/sqlcmd") |
| 36 | + }) |
| 37 | + |
| 38 | + t.Run("2022-CU17/new-version", func(t *testing.T) { |
| 39 | + t.Parallel() |
| 40 | + assertSQLCmdPath(t, "mcr.microsoft.com/mssql/server:2022-CU17-ubuntu-22.04", "/opt/mssql-tools18/bin/sqlcmd") |
| 41 | + }) |
| 42 | + |
| 43 | + t.Run("2025-CU14/new-version", func(t *testing.T) { |
| 44 | + t.Parallel() |
| 45 | + assertSQLCmdPath(t, "mcr.microsoft.com/mssql/server:2025-CU14-ubuntu-22.04", "/opt/mssql-tools18/bin/sqlcmd") |
| 46 | + }) |
| 47 | +} |
0 commit comments