core: Fix TestContext2Apply_countDecrease

This test's original outcome was invalid because it didn't actually
configure a mock apply function, and so _any_ apply operation would appear
to have destroyed the object it was given. This was visible in the fact
that the configuration contains aws_instance.bar but yet it was not
present in the expected state string.

Now we use the standard testApplyFn, and update the expected output to
include the aws_instance.bar object that is created by a Create change.
This commit is contained in:
Martin Atkins 2018-09-18 14:50:19 -07:00
parent 8db60c0c35
commit 3b89930f6f
2 changed files with 11 additions and 4 deletions

View File

@ -2077,6 +2077,7 @@ func TestContext2Apply_countDecrease(t *testing.T) {
m := testModule(t, "apply-count-dec")
p := testProvider("aws")
p.DiffFn = testDiffFn
p.ApplyFn = testApplyFn
s := mustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
@ -2127,13 +2128,12 @@ func TestContext2Apply_countDecrease(t *testing.T) {
})
if _, diags := ctx.Plan(); diags.HasErrors() {
t.Fatalf("plan errors: %s", diags.Err())
logDiagnostics(t, diags)
t.Fatal("plan failed")
}
state, diags := ctx.Apply()
if diags.HasErrors() {
t.Fatalf("diags: %s", diags.Err())
}
assertNoErrors(t, diags)
actual := strings.TrimSpace(state.String())
expected := strings.TrimSpace(testTerraformApplyCountDecStr)

View File

@ -438,12 +438,19 @@ aws_instance.foo:
`
const testTerraformApplyCountDecStr = `
aws_instance.bar:
ID = foo
provider = provider.aws
foo = bar
type = aws_instance
aws_instance.foo.0:
ID = bar
provider = provider.aws
foo = foo
type = aws_instance
aws_instance.foo.1:
ID = bar
provider = provider.aws
foo = foo
type = aws_instance
`