From b5156eecc7ad6a97ff7b4379d51f23c1f68424da Mon Sep 17 00:00:00 2001
From: Christopher Crone <christopher.crone@docker.com>
Date: Thu, 21 May 2020 09:26:02 +0200
Subject: [PATCH] Simplify e2e suite helpers

Signed-off-by: Christopher Crone <christopher.crone@docker.com>
---
 tests/framework/suite.go | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/tests/framework/suite.go b/tests/framework/suite.go
index fa88b6ee0..c962b9794 100644
--- a/tests/framework/suite.go
+++ b/tests/framework/suite.go
@@ -38,7 +38,6 @@ import (
 
 	"github.com/onsi/gomega"
 	log "github.com/sirupsen/logrus"
-	"github.com/stretchr/testify/require"
 	"github.com/stretchr/testify/suite"
 )
 
@@ -58,8 +57,9 @@ func (s *Suite) SetupSuite() {
 		cp := filepath.Join(s.ConfigDir, "config.json")
 		d, _ := ioutil.ReadFile(cp)
 		fmt.Printf("Contents of %s:\n%s\n\nContents of config dir:\n", cp, string(d))
-		out, _ := s.NewCommand("find", s.ConfigDir).Exec()
-		fmt.Println(out)
+		for _, p := range dirContents(s.ConfigDir) {
+			fmt.Println(p)
+		}
 		s.T().Fail()
 	})
 	s.linkClassicDocker()
@@ -70,6 +70,15 @@ func (s *Suite) TearDownSuite() {
 	_ = os.RemoveAll(s.BinDir)
 }
 
+func dirContents(dir string) []string {
+	res := []string{}
+	_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
+		res = append(res, filepath.Join(dir, path))
+		return nil
+	})
+	return res
+}
+
 func (s *Suite) linkClassicDocker() {
 	p, err := exec.LookPath("docker")
 	gomega.Expect(err).To(gomega.BeNil())
@@ -83,24 +92,19 @@ func (s *Suite) linkClassicDocker() {
 func (s *Suite) BeforeTest(suite, test string) {
 	d, _ := ioutil.TempDir("", "")
 	s.ConfigDir = d
+	_ = os.Setenv("DOCKER_CONFIG", s.ConfigDir)
 }
 
 // AfterTest is run after each test
 func (s *Suite) AfterTest(suite, test string) {
-	err := os.RemoveAll(s.ConfigDir)
-	require.NoError(s.T(), err)
+	_ = os.RemoveAll(s.ConfigDir)
 }
 
 // NewCommand creates a command context.
 func (s *Suite) NewCommand(command string, args ...string) *CmdContext {
-	var envs []string
-	if s.ConfigDir != "" {
-		envs = append(os.Environ(), fmt.Sprintf("DOCKER_CONFIG=%s", s.ConfigDir))
-	}
 	return &CmdContext{
 		command: command,
 		args:    args,
-		envs:    envs,
 		retries: RetriesContext{interval: time.Second},
 	}
 }