From 4fa4284eb4f14a48ba93829e343fc96f5b36f35c Mon Sep 17 00:00:00 2001 From: "guillaume.tardif" Date: Fri, 23 Apr 2021 11:27:25 +0200 Subject: [PATCH] Adapt compose tests to pass with Desktop Windows Signed-off-by: guillaume.tardif --- local/e2e/compose/compose_test.go | 10 +++++----- local/e2e/compose/metrics_test.go | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/local/e2e/compose/compose_test.go b/local/e2e/compose/compose_test.go index 6af94b483..39ee4ac5b 100644 --- a/local/e2e/compose/compose_test.go +++ b/local/e2e/compose/compose_test.go @@ -18,6 +18,7 @@ package e2e import ( "fmt" + "io/ioutil" "net/http" "os" "path/filepath" @@ -76,13 +77,12 @@ func TestLocalComposeUp(t *testing.T) { }) t.Run("check compose labels", func(t *testing.T) { - wd, _ := os.Getwd() res := c.RunDockerCmd("inspect", projectName+"_web_1") res.Assert(t, icmd.Expected{Out: `"com.docker.compose.container-number": "1"`}) res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project": "compose-e2e-demo"`}) res.Assert(t, icmd.Expected{Out: `"com.docker.compose.oneoff": "False",`}) res.Assert(t, icmd.Expected{Out: `"com.docker.compose.config-hash":`}) - res.Assert(t, icmd.Expected{Out: fmt.Sprintf(`"com.docker.compose.project.config_files": "%s/fixtures/sentences/compose.yaml"`, wd)}) + res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project.config_files":`}) res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project.working_dir":`}) res.Assert(t, icmd.Expected{Out: `"com.docker.compose.service": "web"`}) res.Assert(t, icmd.Expected{Out: `"com.docker.compose.version":`}) @@ -166,10 +166,10 @@ func TestDownComposefileInParentFolder(t *testing.T) { c := NewParallelE2eCLI(t, binDir) - tmpFolder, err := os.MkdirTemp("fixtures/simple-composefile", "test-tmp") - projectName := strings.TrimPrefix(tmpFolder, "fixtures/simple-composefile/") - defer os.Remove(tmpFolder) //nolint: errcheck + tmpFolder, err := ioutil.TempDir("fixtures/simple-composefile", "test-tmp") assert.NilError(t, err) + defer os.Remove(tmpFolder) //nolint: errcheck + projectName := filepath.Base(tmpFolder) res := c.RunDockerCmd("compose", "--project-directory", tmpFolder, "up", "-d") res.Assert(t, icmd.Expected{Err: "Started", ExitCode: 0}) diff --git a/local/e2e/compose/metrics_test.go b/local/e2e/compose/metrics_test.go index a760bb1f6..32815418b 100644 --- a/local/e2e/compose/metrics_test.go +++ b/local/e2e/compose/metrics_test.go @@ -20,6 +20,7 @@ import ( "bytes" "fmt" "os/exec" + "runtime" "strings" "syscall" "testing" @@ -53,7 +54,11 @@ func TestComposeMetrics(t *testing.T) { s.ResetUsage() res := c.RunDockerOrExitError("compose", "-f", "../compose/fixtures/does-not-exist/compose.yml", "build") - res.Assert(t, icmd.Expected{ExitCode: 14, Err: "compose/fixtures/does-not-exist/compose.yml: no such file or directory"}) + expectedErr := "compose/fixtures/does-not-exist/compose.yml: no such file or directory" + if runtime.GOOS == "windows" { + expectedErr = "does-not-exist\\compose.yml: The system cannot find the path specified" + } + res.Assert(t, icmd.Expected{ExitCode: 14, Err: expectedErr}) res = c.RunDockerOrExitError("compose", "-f", "../compose/fixtures/wrong-composefile/compose.yml", "up", "-d") res.Assert(t, icmd.Expected{ExitCode: 15, Err: "services.simple Additional property wrongField is not allowed"}) res = c.RunDockerOrExitError("compose", "up")