core: test that we skip hooks for data source destroy

Data source destroy is an implementation detail and not something that
external callers should see or expect.
pull/15973/head
Martin Atkins 9 years ago
parent e7a0aa96c8
commit 892f60efe0

@ -1519,6 +1519,7 @@ func TestContext2Apply_destroyData(t *testing.T) {
},
},
}
hook := &testHook{}
ctx := testContext2(t, &ContextOpts{
Module: m,
ProviderResolver: ResourceProviderResolverFixed(
@ -1528,6 +1529,7 @@ func TestContext2Apply_destroyData(t *testing.T) {
),
State: state,
Destroy: true,
Hooks: []Hook{hook},
})
if p, err := ctx.Plan(); err != nil {
@ -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

Loading…
Cancel
Save