Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions cli/cmd/context/ls_test.go

This file was deleted.

31 changes: 8 additions & 23 deletions context/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,6 @@ func (suite *StoreTestSuite) TestGet() {
require.Equal(suite.T(), "type", meta.Type)
}

func (suite *StoreTestSuite) TestList() {
err := suite.store.Create("test1", "type", "description", ContextMetadata{})
require.Nil(suite.T(), err)

err = suite.store.Create("test2", "type", "description", ContextMetadata{})
require.Nil(suite.T(), err)

contexts, err := suite.store.List()
require.Nil(suite.T(), err)

require.Equal(suite.T(), len(contexts), 3)
require.Equal(suite.T(), "test1", contexts[0].Name)
require.Equal(suite.T(), "test2", contexts[1].Name)
require.Equal(suite.T(), "default", contexts[2].Name)
}

func (suite *StoreTestSuite) TestRemoveNotFound() {
err := suite.store.Remove("notfound")
require.EqualError(suite.T(), err, `context "notfound": not found`)
Expand All @@ -132,17 +116,18 @@ func (suite *StoreTestSuite) TestRemoveNotFound() {
func (suite *StoreTestSuite) TestRemove() {
err := suite.store.Create("testremove", "type", "description", ContextMetadata{})
require.Nil(suite.T(), err)
contexts, err := suite.store.List()

meta, err := suite.store.Get("testremove")
require.Nil(suite.T(), err)
require.Equal(suite.T(), len(contexts), 2)
require.NotNil(suite.T(), meta)

err = suite.store.Remove("testremove")
require.Nil(suite.T(), err)
contexts, err = suite.store.List()
require.Nil(suite.T(), err)
// The default context is always here, that's why we
// have len(contexts) == 1
require.Equal(suite.T(), len(contexts), 1)

meta, err = suite.store.Get("testremove")
require.EqualError(suite.T(), err, `context "testremove": not found`)
require.Nil(suite.T(), meta)

}

func TestExampleTestSuite(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion context/store/storedefault.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type endpoint struct {
}

func dockerDefaultContext() (*Metadata, error) {
cmd := exec.Command("docker", "context", "inspect", "default")
cmd := exec.Command("docker-classic", "context", "inspect", "default")
var stdout bytes.Buffer
cmd.Stdout = &stdout
err := cmd.Run()
Expand Down
13 changes: 0 additions & 13 deletions context/store/storedefault_test.go

This file was deleted.

8 changes: 4 additions & 4 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"testing"
"time"

"gotest.tools/golden"

. "github.com/onsi/gomega"
"github.com/stretchr/testify/suite"

Expand All @@ -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")
})
}

Expand Down Expand Up @@ -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"))
})
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/testdata/ls-out-default.golden
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NAME TYPE DESCRIPTION DOCKER ENPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default docker Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
example * example
test-example * example
13 changes: 10 additions & 3 deletions tests/framework/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -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.
Expand Down