summaryrefslogtreecommitdiff
path: root/test/kpod_run.bats
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-11-07 10:03:46 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-20 16:25:31 +0000
commit57599f0075ccab859d4158f7ee891b9b971c731f (patch)
tree84bb48fc3ef1321a29816710cbb1221cc598b745 /test/kpod_run.bats
parent3b72af614777b966671ad0eb0c5dbde0eeedcfa2 (diff)
downloadpodman-57599f0075ccab859d4158f7ee891b9b971c731f.tar.gz
podman-57599f0075ccab859d4158f7ee891b9b971c731f.tar.bz2
podman-57599f0075ccab859d4158f7ee891b9b971c731f.zip
Fix up handling of environment variables
The way docker works is if a user specifies a non `-e Name=Value`, IE just a `-e Name`, then the environment variable Name from the clients OS.ENV is used. Also by default Docker containers run with the HOSTNAME environment set to the HOSTNAME specified for the container. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #21 Approved by: baude
Diffstat (limited to 'test/kpod_run.bats')
-rw-r--r--test/kpod_run.bats31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/kpod_run.bats b/test/kpod_run.bats
index 56995316b..fa5fada55 100644
--- a/test/kpod_run.bats
+++ b/test/kpod_run.bats
@@ -60,3 +60,34 @@ ALPINE="docker.io/library/alpine:latest"
[ "$status" -eq 0 ]
}
+
+@test "run environment test" {
+
+ ${KPOD_BINARY} ${KPOD_OPTIONS} pull ${ALPINE}
+
+ run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -env FOO=BAR ${ALPINE} printenv FOO | tr -d '\r'"
+ echo "$output"
+ [ "$status" -eq 0 ]
+ [ $output = "BAR" ]
+
+ run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -env PATH="/bin" ${ALPINE} printenv PATH | tr -d '\r'"
+ echo "$output"
+ [ "$status" -eq 0 ]
+ [ $output = "/bin" ]
+
+ run bash -c "export FOO=BAR; ${KPOD_BINARY} ${KPOD_OPTIONS} run -env FOO ${ALPINE} printenv FOO | tr -d '\r'"
+ echo "$output"
+ [ "$status" -eq 0 ]
+ [ "$output" = "BAR" ]
+
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} run -env FOO ${ALPINE} printenv
+ echo "$output"
+ [ "$status" -ne 0 ]
+
+# We don't currently set the hostname in containers, since we are not setting up
+# networking. As soon as kpod run gets network support we need to uncomment this
+# test.
+# run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run ${ALPINE} sh -c printenv | grep HOSTNAME"
+# echo "$output"
+# [ "$status" -eq 0 ]
+}