summaryrefslogtreecommitdiffhomepage
path: root/test/e2e/exec_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/exec_test.go')
-rw-r--r--test/e2e/exec_test.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go
index 88d26e865..c962a3159 100644
--- a/test/e2e/exec_test.go
+++ b/test/e2e/exec_test.go
@@ -208,8 +208,27 @@ func TestExecEnv(t *testing.T) {
if err != nil {
t.Fatalf("docker exec failed: %v", err)
}
- if want := "BAR"; !strings.Contains(got, want) {
- t.Errorf("wanted exec output to contain %q, got %q", want, got)
+ if got, want := strings.TrimSpace(got), "BAR"; got != want {
+ t.Errorf("bad output from 'docker exec'. Got %q; Want %q.", got, want)
+ }
+}
+
+// TestRunEnvHasHome tests that run always has HOME environment set.
+func TestRunEnvHasHome(t *testing.T) {
+ // Base alpine image does not have any environment variables set.
+ if err := dockerutil.Pull("alpine"); err != nil {
+ t.Fatalf("docker pull failed: %v", err)
+ }
+ d := dockerutil.MakeDocker("run-env-test")
+
+ // Exec "echo $HOME". The 'bin' user's home dir is '/bin'.
+ got, err := d.RunFg("--user", "bin", "alpine", "/bin/sh", "-c", "echo $HOME")
+ if err != nil {
+ t.Fatalf("docker run failed: %v", err)
+ }
+ defer d.CleanUp()
+ if got, want := strings.TrimSpace(got), "/bin"; got != want {
+ t.Errorf("bad output from 'docker run'. Got %q; Want %q.", got, want)
}
}