diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index d54e57acc..7ba95e8d5 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -1055,7 +1055,7 @@ func setupDockerVolumes(t *testing.T, cfg *config.Config, hostpath string) (*str } } - taskEnv, err := GetTaskEnv(allocDir, cfg.Node, task, alloc, "") + taskEnv, err := GetTaskEnv(allocDir, cfg.Node, task, alloc, cfg, "") if err != nil { cleanup() t.Fatalf("Failed to get task env: %v", err) diff --git a/client/driver/driver_test.go b/client/driver/driver_test.go index 903689966..a8b1742fd 100644 --- a/client/driver/driver_test.go +++ b/client/driver/driver_test.go @@ -84,7 +84,7 @@ func testDriverContexts(task *structs.Task) (*DriverContext, *ExecContext) { alloc := mock.Alloc() execCtx := NewExecContext(allocDir, alloc.ID) - taskEnv, err := GetTaskEnv(allocDir, cfg.Node, task, alloc, "") + taskEnv, err := GetTaskEnv(allocDir, cfg.Node, task, alloc, cfg, "") if err != nil { return nil, nil } @@ -123,7 +123,7 @@ func TestDriver_GetTaskEnv(t *testing.T) { alloc := mock.Alloc() alloc.Name = "Bar" - env, err := GetTaskEnv(nil, nil, task, alloc, "") + env, err := GetTaskEnv(nil, nil, task, alloc, testConfig(), "") if err != nil { t.Fatalf("GetTaskEnv() failed: %v", err) } @@ -161,8 +161,17 @@ func TestDriver_GetTaskEnv(t *testing.T) { } act := env.EnvMap() - if !reflect.DeepEqual(act, exp) { - t.Fatalf("GetTaskEnv() returned %#v; want %#v", act, exp) + + // Since host env vars are included only ensure expected env vars are present + for expk, expv := range exp { + v, ok := act[expk] + if !ok { + t.Errorf("%q not found in task env", expk) + continue + } + if v != expv { + t.Errorf("Expected %s=%q but found %q", expk, expv, v) + } } }