Fix tests broken by TaskEnv change

This commit is contained in:
Michael Schurter 2016-12-20 14:37:35 -08:00
parent 0d90e96925
commit 39f587a2af
2 changed files with 14 additions and 5 deletions

View file

@ -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)

View file

@ -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)
}
}
}