|
| 1 | +package integration_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "runtime" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/localstack/lstk/test/integration/env" |
| 8 | + "github.com/stretchr/testify/assert" |
| 9 | + "github.com/stretchr/testify/require" |
| 10 | +) |
| 11 | + |
| 12 | +// windowsDockerErrorEnv returns an Environ with an invalid DOCKER_HOST and no PSModulePath. |
| 13 | +func windowsDockerErrorEnv() env.Environ { |
| 14 | + return env.Without(env.Key("PSModulePath"), env.Key("DOCKER_HOST")). |
| 15 | + With(env.AuthToken, "fake-token"). |
| 16 | + With(env.Key("DOCKER_HOST"), "tcp://localhost:1") |
| 17 | +} |
| 18 | + |
| 19 | +// Verifies that when docker is in PATH, lstk suggests "docker desktop start". |
| 20 | +func TestWindowsDockerErrorShowsDockerCLICommand(t *testing.T) { |
| 21 | + if runtime.GOOS != "windows" { |
| 22 | + t.Skip("Windows-only test") |
| 23 | + } |
| 24 | + |
| 25 | + stdout, _, err := runLstk(t, testContext(t), "", windowsDockerErrorEnv(), "start") |
| 26 | + require.Error(t, err) |
| 27 | + requireExitCode(t, 1, err) |
| 28 | + assert.Contains(t, stdout, "docker desktop start") |
| 29 | +} |
| 30 | + |
| 31 | +// Verifies that the verbose Docker error message is suppressed on Windows. |
| 32 | +func TestWindowsDockerErrorOmitsVerboseSummary(t *testing.T) { |
| 33 | + if runtime.GOOS != "windows" { |
| 34 | + t.Skip("Windows-only test") |
| 35 | + } |
| 36 | + |
| 37 | + stdout, _, err := runLstk(t, testContext(t), "", windowsDockerErrorEnv(), "start") |
| 38 | + require.Error(t, err) |
| 39 | + requireExitCode(t, 1, err) |
| 40 | + assert.Contains(t, stdout, "Docker is not available") |
| 41 | + assert.NotContains(t, stdout, "cannot connect to Docker daemon") |
| 42 | +} |
0 commit comments