Fix test to assert new never-nil behavior

This commit is contained in:
Michael Schurter 2017-02-10 10:11:15 -08:00
parent 51e4fe9915
commit fb59e42473
1 changed files with 5 additions and 7 deletions

View File

@ -1285,9 +1285,9 @@ func TestTaskRunner_SimpleRun_Dispatch(t *testing.T) {
}
}
// TestTaskRunner_CleanupNil ensures TaskRunner doesn't call Driver.Cleanup if
// no resources were created.
func TestTaskRunner_CleanupNil(t *testing.T) {
// TestTaskRunner_CleanupEmpty ensures TaskRunner works when createdResources
// is empty.
func TestTaskRunner_CleanupEmpty(t *testing.T) {
alloc := mock.Alloc()
task := alloc.Job.TaskGroups[0].Tasks[0]
task.Driver = "mock_driver"
@ -1295,14 +1295,12 @@ func TestTaskRunner_CleanupNil(t *testing.T) {
ctx := testTaskRunnerFromAlloc(t, false, alloc)
ctx.tr.MarkReceived()
ctx.tr.createdResources = nil
defer ctx.Cleanup()
ctx.tr.Run()
// Since we only failed once, createdResources should be empty
if ctx.tr.createdResources != nil {
t.Fatalf("createdResources should still be nil: %v", ctx.tr.createdResources)
if len(ctx.tr.createdResources.Resources) != 0 {
t.Fatalf("createdResources should still be empty: %v", ctx.tr.createdResources)
}
}