docker_cli_run_test: Preserve DOCKER_TEST_HOST in env-clearing tests

For Windows, we run integration-cli with DOCKER_TEST_HOST env var b/c
daemon is on some remote machine. This keeps the DOCKER_HOST set by
bash scripts in the env.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
Upstream-commit: 4f377fbe9f30ea44be5e10a0c7b9bc3c6eb421b1
Component: engine
This commit is contained in:
Ahmet Alp Balkan
2015-02-12 11:20:48 -08:00
parent 3de3653c91
commit b18c3b3d5b
2 changed files with 14 additions and 2 deletions

View File

@ -893,3 +893,13 @@ func setupRegistry(t *testing.T) func() {
return func() { reg.Close() }
}
// appendDockerHostEnv adds given env slice DOCKER_HOST value if set in the
// environment. Useful when environment is cleared but we want to preserve DOCKER_HOST
// to execute tests against a remote daemon.
func appendDockerHostEnv(env []string) []string {
if dockerHost := os.Getenv("DOCKER_HOST"); dockerHost != "" {
env = append(env, fmt.Sprintf("DOCKER_HOST=%s", dockerHost))
}
return env
}