Skip to content

Commit

Permalink
core: test that we skip hooks for data source destroy
Browse files Browse the repository at this point in the history
Data source destroy is an implementation detail and not something that
external callers should see or expect.
  • Loading branch information
apparentlymart committed Sep 2, 2017
1 parent e7a0aa9 commit 892f60e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions terraform/context_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ func TestContext2Apply_destroyData(t *testing.T) {
},
},
}
hook := &testHook{}
ctx := testContext2(t, &ContextOpts{
Module: m,
ProviderResolver: ResourceProviderResolverFixed(
Expand All @@ -1528,6 +1529,7 @@ func TestContext2Apply_destroyData(t *testing.T) {
),
State: state,
Destroy: true,
Hooks: []Hook{hook},
})

if p, err := ctx.Plan(); err != nil {
Expand All @@ -1548,6 +1550,15 @@ func TestContext2Apply_destroyData(t *testing.T) {
if got := len(newState.Modules[0].Resources); got != 0 {
t.Fatalf("state has %d resources after destroy; want 0", got)
}

wantHookCalls := []*testHookCall{
{"PreDiff", "data.null_data_source.testing"},
{"PostDiff", "data.null_data_source.testing"},
{"PostStateUpdate", ""},
}
if !reflect.DeepEqual(hook.Calls, wantHookCalls) {
t.Errorf("wrong hook calls\ngot: %swant: %s", spew.Sdump(hook.Calls), spew.Sdump(wantHookCalls))
}
}

// https://github.com/hashicorp/terraform/pull/5096
Expand Down

0 comments on commit 892f60e

Please sign in to comment.