Fix shell out to docker-classic when invoking

This commit is contained in:
Guillaume Tardif 2020-05-26 23:34:38 +02:00
parent d876f9e779
commit d2648da2d9
8 changed files with 26 additions and 70 deletions

View file

@ -34,6 +34,8 @@ import (
"testing"
"time"
"gotest.tools/golden"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/suite"
@ -56,12 +58,10 @@ func (s *E2eSuite) TestContextHelp() {
func (s *E2eSuite) TestContextDefault() {
It("should be initialized with default context", func() {
s.NewDockerCommand("context", "use", "default").ExecOrDie()
output := s.NewDockerCommand("context", "show").ExecOrDie()
Expect(output).To(ContainSubstring("default"))
output = s.NewCommand("docker", "context", "ls").ExecOrDie()
Expect(output).To(Not(ContainSubstring("test-example")))
Expect(output).To(ContainSubstring("default *"))
golden.Assert(s.T(), output, "ls-out-default.golden")
})
}
@ -93,7 +93,7 @@ func (s *E2eSuite) TestMockBackend() {
currentContext := s.NewDockerCommand("context", "use", "test-example").ExecOrDie()
Expect(currentContext).To(ContainSubstring("test-example"))
output := s.NewDockerCommand("context", "ls").ExecOrDie()
Expect(output).To(ContainSubstring("test-example *"))
golden.Assert(s.T(), output, "ls-out-test-example.golden")
output = s.NewDockerCommand("context", "show").ExecOrDie()
Expect(output).To(ContainSubstring("test-example"))
})

View file

@ -0,0 +1,2 @@
NAME TYPE DESCRIPTION DOCKER ENPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * docker Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm

View file

@ -0,0 +1,3 @@
NAME TYPE DESCRIPTION DOCKER ENPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default docker Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
test-example * example

View file

@ -80,10 +80,17 @@ func dirContents(dir string) []string {
}
func (s *Suite) linkClassicDocker() {
p, err := exec.LookPath("docker")
p, err := exec.LookPath("docker-classic")
if err != nil {
p, err = exec.LookPath("docker")
}
gomega.Expect(err).To(gomega.BeNil())
err = os.Symlink(p, filepath.Join(s.BinDir, "docker-classic"))
gomega.Expect(err).To(gomega.BeNil())
dockerPath, err := filepath.Abs("../../bin/docker")
gomega.Expect(err).To(gomega.BeNil())
err = os.Symlink(dockerPath, filepath.Join(s.BinDir, "docker"))
gomega.Expect(err).To(gomega.BeNil())
err = os.Setenv("PATH", fmt.Sprintf("%s:%s", s.BinDir, os.Getenv("PATH")))
gomega.Expect(err).To(gomega.BeNil())
}
@ -111,9 +118,9 @@ func (s *Suite) NewCommand(command string, args ...string) *CmdContext {
func dockerExecutable() string {
if runtime.GOOS == "windows" {
return "../../bin/docker.exe"
return "docker.exe"
}
return "../../bin/docker"
return "docker"
}
// NewDockerCommand creates a docker builder.