From f3f6bff583480faed6aa8c54e35e0a87fef01b62 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 8 Jun 2020 17:30:46 +0200 Subject: [PATCH] Fix linter --- tests/framework/helper.go | 8 +++++++- tests/framework/suite.go | 15 ++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/framework/helper.go b/tests/framework/helper.go index cd18b8599..d3353f05f 100644 --- a/tests/framework/helper.go +++ b/tests/framework/helper.go @@ -49,13 +49,19 @@ func Columns(line string) []string { return filter.Choose(strings.Split(line, " "), nonEmptyString).([]string) } +// GoldenFile golden file specific to platform func GoldenFile(name string) string { - if runtime.GOOS == "windows" { + if IsWindows() { return name + "-windows.golden" } return name + ".golden" } +// IsWindows windows or other GOOS +func IsWindows() bool { + return runtime.GOOS == "windows" +} + // It runs func func It(description string, test func()) { test() diff --git a/tests/framework/suite.go b/tests/framework/suite.go index 9ff6e5ef6..8a33b2f90 100644 --- a/tests/framework/suite.go +++ b/tests/framework/suite.go @@ -33,7 +33,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "time" "github.com/onsi/gomega" @@ -56,6 +55,7 @@ func (s *Suite) SetupSuite() { log.Error(message) cp := filepath.Join(s.ConfigDir, "config.json") d, _ := ioutil.ReadFile(cp) + fmt.Printf("Bin dir:%s\n", s.BinDir) fmt.Printf("Contents of %s:\n%s\n\nContents of config dir:\n", cp, string(d)) for _, p := range dirContents(s.ConfigDir) { fmt.Println(p) @@ -85,23 +85,23 @@ func (s *Suite) copyExecutablesInBinDir() { p, err = exec.LookPath(dockerExecutable()) } gomega.Expect(err).To(gomega.BeNil()) - err = copyFiles(p, filepath.Join(s.BinDir, DockerClassicExecutable())) + err = copyFile(p, filepath.Join(s.BinDir, DockerClassicExecutable())) gomega.Expect(err).To(gomega.BeNil()) dockerPath, err := filepath.Abs("../../bin/" + dockerExecutable()) gomega.Expect(err).To(gomega.BeNil()) - err = copyFiles(dockerPath, filepath.Join(s.BinDir, dockerExecutable())) + err = copyFile(dockerPath, filepath.Join(s.BinDir, dockerExecutable())) 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()) } -func copyFiles(sourceFile string, destinationFile string) error { +func copyFile(sourceFile string, destinationFile string) error { input, err := ioutil.ReadFile(sourceFile) if err != nil { return err } - err = ioutil.WriteFile(destinationFile, input, 0644) + err = ioutil.WriteFile(destinationFile, input, 0777) if err != nil { return err } @@ -128,10 +128,6 @@ func (s *Suite) ListProcessesCommand() *CmdContext { return s.NewCommand("ps") } -func IsWindows() bool { - return runtime.GOOS == "windows" -} - // NewCommand creates a command context. func (s *Suite) NewCommand(command string, args ...string) *CmdContext { return &CmdContext{ @@ -148,6 +144,7 @@ func dockerExecutable() string { return "docker" } +// DockerClassicExecutable binary name based on platform func DockerClassicExecutable() string { if IsWindows() { return "docker-classic.exe"