Adapt compose tests to pass with Desktop Windows

Signed-off-by: guillaume.tardif <guillaume.tardif@gmail.com>
This commit is contained in:
guillaume.tardif 2021-04-23 11:27:25 +02:00 committed by Guillaume Tardif
parent ad42fc6c4d
commit 4fa4284eb4
2 changed files with 11 additions and 6 deletions

View File

@ -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})

View File

@ -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")