Skip to content

Commit

Permalink
fix: Fix run -e/--env tests and add missing variable redefinition (#22)
Browse files Browse the repository at this point in the history
Issue #, if available:

*Description of changes:*
Currently `run -e/--env` tests don't use the env loop variable, instead
they are hardcoded into the test string. We need to use the env loop
variable.

*Testing done:*



- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Ang Zhou <angzh@amazon.com>
  • Loading branch information
azhouwd authored Jan 17, 2023
1 parent 4c3af58 commit 84960f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/network_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func NetworkCreate(o *option.Option) {
for _, driverFlag := range []string{"-d", "--driver"} {
driverFlag := driverFlag
for _, driver := range []string{"macvlan", "ipvlan"} {
driver := 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 84960f8

Please sign in to comment.