Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Move compose e2e tests into pkg #1847

Merged
merged 1 commit into from
Jun 29, 2021
Merged

Conversation

ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Jun 25, 2021

What I did
moved compose e2e tests into pkg so all the compose.v2 code is now isolated from compose-cli

@ndeloof ndeloof requested review from lorenrh and ulyssessouza June 25, 2021 15:10
@github-actions github-actions bot added the local Local context (moby) label Jun 25, 2021
@ndeloof ndeloof force-pushed the compose_e2e branch 2 times, most recently from 2f36978 to 08d19de Compare June 25, 2021 16:14
@github-actions github-actions bot added the ci Continuous integration label Jun 25, 2021
@ndeloof ndeloof force-pushed the compose_e2e branch 8 times, most recently from c5c9c56 to 1b5bfb8 Compare June 26, 2021 14:14
Signed-off-by: Nicolas De Loof <[email protected]>
}
}

return &E2eCLI{binDir, d, t}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ignoring err if it’s different from «is not exist»?

}

func dirContents(dir string) []string {
res := []string{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
res := []string{}
var res []string

_ = os.RemoveAll(d)
})

_ = os.MkdirAll(filepath.Join(d, "cli-plugins"), 0755)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ignoring the error?


func findExecutable(executableName string, paths []string) (string, error) {
for _, p := range paths {
bin, err := filepath.Abs(path.Join(p, executableName))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably use filepath.Join?

Suggested change
bin, err := filepath.Abs(path.Join(p, executableName))
bin, err := filepath.Abs(filepath.Join(p, executableName))

return bin, nil
}

return "", errors.Wrap(os.ErrNotExist, "executable not found")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: adding context text to wrapped errors are suggested to be of the form

Suggested change
return "", errors.Wrap(os.ErrNotExist, "executable not found")
return "", errors.Wrap(os.ErrNotExist, "looking for executable")

as there is usually a good chance the error already including something around «not found» and this would just add some repetition

})

t.Run("do not display if scan already invoked", func(t *testing.T) {
_ = os.MkdirAll(filepath.Join(c.ConfigDir, "scan"), 0755)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for ignoring the error here?

Comment on lines +92 to +93
err = CopyFile(composePlugin, filepath.Join(d, "cli-plugins", composePluginFile))
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
err = CopyFile(composePlugin, filepath.Join(d, "cli-plugins", composePluginFile))
if err != nil {
if err := CopyFile(composePlugin, filepath.Join(d, "cli-plugins", composePluginFile)); err != nil {

Comment on lines +41 to +48
DockerExecutableName = "docker"
)

func init() {
if runtime.GOOS == "windows" {
DockerExecutableName = DockerExecutableName + ".exe"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

Suggested change
DockerExecutableName = "docker"
)
func init() {
if runtime.GOOS == "windows" {
DockerExecutableName = DockerExecutableName + ".exe"
}
}
DockerExecutableName = "docker" + binExt()
)
func binExt() string {
if runtime.GOOS == "windows" {
return ".exe"
}
return ""
}

It can be re-used further down.

composePluginFile += ".exe"
scanPluginFile += ".exe"
}
composePlugin, err := findExecutable(composePluginFile, []string{"../../bin", "../../../bin"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be

Suggested change
composePlugin, err := findExecutable(composePluginFile, []string{"../../bin", "../../../bin"})
composePlugin, err := findExecutable(composePluginFile, "../../bin", "../../../bin")

with

 func findExecutable(executableName string, paths ...string) (string, error) {

Comment on lines +108 to +109
_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
res = append(res, filepath.Join(dir, path))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we ignoring errors?

@ndeloof
Copy link
Collaborator Author

ndeloof commented Jun 28, 2021

@mat007 thanks for the review, but the intent here is not to review the existing tests, but to get them moved into compose.v2 pkg, isolated from compose-cli
We can create a "test cleanup" task if you think this makes sense

Copy link
Contributor

@lorenrh lorenrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in on creating a follow-up task for test cleanup 😅

@ndeloof ndeloof merged commit 53eca14 into docker-archive:main Jun 29, 2021
@ndeloof ndeloof deleted the compose_e2e branch June 29, 2021 15:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ci Continuous integration local Local context (moby)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants