diff --git a/terraform/context_test.go b/terraform/context_test.go index 7aba50395..dfe5cf0a9 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -1108,6 +1108,54 @@ func TestContextApply_countDecreaseToOne(t *testing.T) { } } +func TestContextApply_countTainted(t *testing.T) { + m := testModule(t, "apply-count-tainted") + p := testProvider("aws") + p.DiffFn = testDiffFn + s := &State{ + Modules: []*ModuleState{ + &ModuleState{ + Path: rootModulePath, + Resources: map[string]*ResourceState{ + "aws_instance.foo.0": &ResourceState{ + Type: "aws_instance", + Tainted: []*InstanceState{ + &InstanceState{ + ID: "bar", + Attributes: map[string]string{ + "foo": "foo", + "type": "aws_instance", + }, + }, + }, + }, + }, + }, + }, + } + ctx := testContext(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + State: s, + }) + + if _, err := ctx.Plan(nil); err != nil { + t.Fatalf("err: %s", err) + } + + state, err := ctx.Apply() + if err != nil { + t.Fatalf("err: %s", err) + } + + actual := strings.TrimSpace(state.String()) + expected := strings.TrimSpace(testTerraformApplyCountTaintedStr) + if actual != expected { + t.Fatalf("bad: \n%s", actual) + } +} func TestContextApply_module(t *testing.T) { m := testModule(t, "apply-module") p := testProvider("aws") diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 98c078a73..51e1324cf 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -224,6 +224,10 @@ aws_instance.foo.0: type = aws_instance ` +const testTerraformApplyCountTaintedStr = ` + +` + const testTerraformApplyMinimalStr = ` aws_instance.bar: ID = foo diff --git a/terraform/test-fixtures/apply-count-tainted/main.tf b/terraform/test-fixtures/apply-count-tainted/main.tf new file mode 100644 index 000000000..ba35b0343 --- /dev/null +++ b/terraform/test-fixtures/apply-count-tainted/main.tf @@ -0,0 +1,4 @@ +resource "aws_instance" "foo" { + count = 2 + foo = "foo" +}