Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix run -e/--env tests and add missing variable redefinition #22

Merged
merged 2 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion tests/network_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func NetworkCreate(o *option.Option) {
})

for _, driverFlag := range []string{"-d", "--driver"} {
driverFlag := driverFlag
for _, driver := range []string{"macvlan", "ipvlan"} {
driverFlag, driver := driverFlag, driver
ginkgo.It(fmt.Sprintf("should create %s network with %s flag", driver, driverFlag), func() {
command.Run(o, "network", "create", driverFlag, driver, testNetwork)
netType := command.StdoutStr(o, "network", "inspect", testNetwork, "--mode=native",
Expand Down
4 changes: 3 additions & 1 deletion tests/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,18 @@ func Run(o *RunOption) {
})

for _, workDir := range []string{"--workdir", "-w"} {
workDir := workDir
ginkgo.It(fmt.Sprintf("should set working directory inside the container specified by %s flag", workDir), func() {
dir := "/tmp"
gomega.Expect(command.StdoutStr(o.BaseOpt, "run", workDir, dir, defaultImage, "pwd")).Should(gomega.Equal(dir))
})
}

for _, env := range []string{"-e", "--env"} {
env := env
ginkgo.It(fmt.Sprintf("with %s flag, environment variables should be set in the container", env), func() {
envOutput := command.Stdout(o.BaseOpt, "run", "--rm",
"--env", "FOO=BAR", "--env", "FOO1", "-e", "ENV1=1", "-e", "ENV1=2",
env, "FOO=BAR", env, "FOO1", env, "ENV1=1", env, "ENV1=2",
defaultImage, "env")
gomega.Expect(envOutput).To(gomega.ContainSubstring("FOO=BAR"))
gomega.Expect(envOutput).ToNot(gomega.ContainSubstring("FOO1"))
Expand Down