Skip to content

Commit

Permalink
Fix run -e/--env tests and add missing variable redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
azhouwd committed Jan 17, 2023
1 parent 4c3af58 commit d6357a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit d6357a5

Please sign in to comment.