core: ApplyGraphBuilder tests to use the "test" mock provider

These tests now need schema available to run properly, so rather than
crafting a separate schema for each of these we'll just use the one
created by simpleMockProvider, which contains a resource type called
test_object that we'll now use as the basis for all of the tests here.
This commit is contained in:
Martin Atkins 2018-05-10 15:38:58 -07:00
parent f475b3b931
commit e1bc27ef6c
12 changed files with 186 additions and 272 deletions

View File

@ -1,7 +1,6 @@
package terraform package terraform
import ( import (
"fmt"
"strings" "strings"
"testing" "testing"
@ -19,20 +18,20 @@ func TestApplyGraphBuilder(t *testing.T) {
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
// Verify noop doesn't show up in graph // Verify noop doesn't show up in graph
"aws_instance.noop": &InstanceDiff{}, "test_object.noop": &InstanceDiff{},
"aws_instance.create": &InstanceDiff{ "test_object.create": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
}, },
}, },
"aws_instance.other": &InstanceDiff{ "test_object.other": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -44,18 +43,18 @@ func TestApplyGraphBuilder(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root", "child"}, Path: []string{"root", "child"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"aws_instance.create": &InstanceDiff{ "test_object.create": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
}, },
}, },
"aws_instance.other": &InstanceDiff{ "test_object.other": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -69,18 +68,7 @@ func TestApplyGraphBuilder(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-basic"), Config: testModule(t, "graph-builder-apply-basic"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"aws": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
provisioners: map[string]ResourceProvisionerFactory{
"exec": func() (ResourceProvisioner, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
DisableReduce: true, DisableReduce: true,
} }
@ -96,7 +84,7 @@ func TestApplyGraphBuilder(t *testing.T) {
actual := strings.TrimSpace(g.String()) actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(testApplyGraphBuilderStr) expected := strings.TrimSpace(testApplyGraphBuilderStr)
if actual != expected { if actual != expected {
t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual) t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
} }
} }
@ -107,9 +95,9 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
Modules: []*ModuleDiff{ Modules: []*ModuleDiff{
&ModuleDiff{ &ModuleDiff{
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{"aws_instance.A": &InstanceDiff{Destroy: true, Resources: map[string]*InstanceDiff{"test_object.A": &InstanceDiff{Destroy: true,
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
RequiresNew: true, RequiresNew: true,
@ -117,9 +105,9 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
}, },
}, },
"aws_instance.B": &InstanceDiff{ "test_object.B": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -133,18 +121,7 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-dep-cbd"), Config: testModule(t, "graph-builder-apply-dep-cbd"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"aws": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
provisioners: map[string]ResourceProvisionerFactory{
"exec": func() (ResourceProvisioner, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
DisableReduce: true, DisableReduce: true,
} }
@ -162,16 +139,16 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"aws_instance.A", "test_object.A",
"aws_instance.A (destroy)") "test_object.A (destroy)")
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"aws_instance.A", "test_object.A",
"aws_instance.B") "test_object.B")
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"aws_instance.B", "test_object.B",
"aws_instance.A (destroy)") "test_object.A (destroy)")
} }
// This tests the ordering of two resources that are both CBD that // This tests the ordering of two resources that are both CBD that
@ -182,20 +159,20 @@ func TestApplyGraphBuilder_doubleCBD(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"aws_instance.A": &InstanceDiff{ "test_object.A": &InstanceDiff{
Destroy: true, Destroy: true,
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
}, },
}, },
"aws_instance.B": &InstanceDiff{ "test_object.B": &InstanceDiff{
Destroy: true, Destroy: true,
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -209,18 +186,7 @@ func TestApplyGraphBuilder_doubleCBD(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-double-cbd"), Config: testModule(t, "graph-builder-apply-double-cbd"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"aws": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
provisioners: map[string]ResourceProvisionerFactory{
"exec": func() (ResourceProvisioner, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
DisableReduce: true, DisableReduce: true,
} }
@ -236,7 +202,7 @@ func TestApplyGraphBuilder_doubleCBD(t *testing.T) {
actual := strings.TrimSpace(g.String()) actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(testApplyGraphBuilderDoubleCBDStr) expected := strings.TrimSpace(testApplyGraphBuilderDoubleCBDStr)
if actual != expected { if actual != expected {
t.Fatalf("bad: %s", actual) t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
} }
} }
@ -248,11 +214,11 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root", "child"}, Path: []string{"root", "child"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"aws_instance.A": &InstanceDiff{ "test_object.A": &InstanceDiff{
Destroy: true, Destroy: true,
}, },
"aws_instance.B": &InstanceDiff{ "test_object.B": &InstanceDiff{
Destroy: true, Destroy: true,
}, },
}, },
@ -265,21 +231,21 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
&ModuleState{ &ModuleState{
Path: []string{"root", "child"}, Path: []string{"root", "child"},
Resources: map[string]*ResourceState{ Resources: map[string]*ResourceState{
"aws_instance.A": &ResourceState{ "test_object.A": &ResourceState{
Type: "aws_instance", Type: "test_object",
Primary: &InstanceState{ Primary: &InstanceState{
ID: "foo", ID: "foo",
Attributes: map[string]string{}, Attributes: map[string]string{},
}, },
}, },
"aws_instance.B": &ResourceState{ "test_object.B": &ResourceState{
Type: "aws_instance", Type: "test_object",
Primary: &InstanceState{ Primary: &InstanceState{
ID: "bar", ID: "bar",
Attributes: map[string]string{}, Attributes: map[string]string{},
}, },
Dependencies: []string{"aws_instance.A"}, Dependencies: []string{"test_object.A"},
}, },
}, },
}, },
@ -290,13 +256,7 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
Config: testModule(t, "empty"), Config: testModule(t, "empty"),
Diff: diff, Diff: diff,
State: state, State: state,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"aws": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
DisableReduce: true, DisableReduce: true,
} }
@ -312,8 +272,8 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"module.child.aws_instance.B (destroy)", "module.child.test_object.B (destroy)",
"module.child.aws_instance.A (destroy)") "module.child.test_object.A (destroy)")
} }
// This tests the ordering of destroying a single count of a resource. // This tests the ordering of destroying a single count of a resource.
@ -323,11 +283,11 @@ func TestApplyGraphBuilder_destroyCount(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"aws_instance.A.1": &InstanceDiff{ "test_object.A.1": &InstanceDiff{
Destroy: true, Destroy: true,
}, },
"aws_instance.B": &InstanceDiff{ "test_object.B": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "name": &ResourceAttrDiff{
Old: "", Old: "",
@ -343,18 +303,7 @@ func TestApplyGraphBuilder_destroyCount(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-count"), Config: testModule(t, "graph-builder-apply-count"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"aws": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
provisioners: map[string]ResourceProvisionerFactory{
"exec": func() (ResourceProvisioner, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
DisableReduce: true, DisableReduce: true,
} }
@ -370,7 +319,7 @@ func TestApplyGraphBuilder_destroyCount(t *testing.T) {
actual := strings.TrimSpace(g.String()) actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(testApplyGraphBuilderDestroyCountStr) expected := strings.TrimSpace(testApplyGraphBuilderDestroyCountStr)
if actual != expected { if actual != expected {
t.Fatalf("bad: %s", actual) t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
} }
} }
@ -380,7 +329,7 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root", "A"}, Path: []string{"root", "A"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"null_resource.foo": &InstanceDiff{ "test_object.foo": &InstanceDiff{
Destroy: true, Destroy: true,
}, },
}, },
@ -389,7 +338,7 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root", "B"}, Path: []string{"root", "B"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"null_resource.foo": &InstanceDiff{ "test_object.foo": &InstanceDiff{
Destroy: true, Destroy: true,
}, },
}, },
@ -400,13 +349,7 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-module-destroy"), Config: testModule(t, "graph-builder-apply-module-destroy"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"null": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
} }
g, err := b.Build(addrs.RootModuleInstance) g, err := b.Build(addrs.RootModuleInstance)
@ -416,8 +359,9 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"module.B.null_resource.foo (destroy)", "module.B.test_object.foo (destroy)",
"module.A.null_resource.foo (destroy)") "module.A.test_object.foo (destroy)",
)
} }
func TestApplyGraphBuilder_provisioner(t *testing.T) { func TestApplyGraphBuilder_provisioner(t *testing.T) {
@ -426,9 +370,9 @@ func TestApplyGraphBuilder_provisioner(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"null_resource.foo": &InstanceDiff{ "test_object.foo": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -442,18 +386,7 @@ func TestApplyGraphBuilder_provisioner(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-provisioner"), Config: testModule(t, "graph-builder-apply-provisioner"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"null": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
provisioners: map[string]ResourceProvisionerFactory{
"local": func() (ResourceProvisioner, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
} }
g, err := b.Build(addrs.RootModuleInstance) g, err := b.Build(addrs.RootModuleInstance)
@ -461,11 +394,12 @@ func TestApplyGraphBuilder_provisioner(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
testGraphContains(t, g, "provisioner.local") testGraphContains(t, g, "provisioner.test")
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"provisioner.local", "provisioner.test",
"null_resource.foo") "test_object.foo",
)
} }
func TestApplyGraphBuilder_provisionerDestroy(t *testing.T) { func TestApplyGraphBuilder_provisionerDestroy(t *testing.T) {
@ -474,7 +408,7 @@ func TestApplyGraphBuilder_provisionerDestroy(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"null_resource.foo": &InstanceDiff{ "test_object.foo": &InstanceDiff{
Destroy: true, Destroy: true,
}, },
}, },
@ -486,18 +420,7 @@ func TestApplyGraphBuilder_provisionerDestroy(t *testing.T) {
Destroy: true, Destroy: true,
Config: testModule(t, "graph-builder-apply-provisioner"), Config: testModule(t, "graph-builder-apply-provisioner"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"null": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
provisioners: map[string]ResourceProvisionerFactory{
"local": func() (ResourceProvisioner, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
} }
g, err := b.Build(addrs.RootModuleInstance) g, err := b.Build(addrs.RootModuleInstance)
@ -505,11 +428,12 @@ func TestApplyGraphBuilder_provisionerDestroy(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
testGraphContains(t, g, "provisioner.local") testGraphContains(t, g, "provisioner.test")
testGraphHappensBefore( testGraphHappensBefore(
t, g, t, g,
"provisioner.local", "provisioner.test",
"null_resource.foo (destroy)") "test_object.foo (destroy)",
)
} }
func TestApplyGraphBuilder_targetModule(t *testing.T) { func TestApplyGraphBuilder_targetModule(t *testing.T) {
@ -518,9 +442,9 @@ func TestApplyGraphBuilder_targetModule(t *testing.T) {
&ModuleDiff{ &ModuleDiff{
Path: []string{"root"}, Path: []string{"root"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"null_resource.foo": &InstanceDiff{ "test_object.foo": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -528,13 +452,12 @@ func TestApplyGraphBuilder_targetModule(t *testing.T) {
}, },
}, },
}, },
&ModuleDiff{ &ModuleDiff{
Path: []string{"root", "child2"}, Path: []string{"root", "child2"},
Resources: map[string]*InstanceDiff{ Resources: map[string]*InstanceDiff{
"null_resource.foo": &InstanceDiff{ "test_object.foo": &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{ Attributes: map[string]*ResourceAttrDiff{
"name": &ResourceAttrDiff{ "test_string": &ResourceAttrDiff{
Old: "", Old: "",
New: "foo", New: "foo",
}, },
@ -548,13 +471,7 @@ func TestApplyGraphBuilder_targetModule(t *testing.T) {
b := &ApplyGraphBuilder{ b := &ApplyGraphBuilder{
Config: testModule(t, "graph-builder-apply-target-module"), Config: testModule(t, "graph-builder-apply-target-module"),
Diff: diff, Diff: diff,
Components: &basicComponentFactory{ Components: simpleMockComponentFactory(),
providers: map[string]ResourceProviderFactory{
"null": func() (ResourceProvider, error) {
return nil, fmt.Errorf("not implemented")
},
},
},
Targets: []addrs.Targetable{ Targets: []addrs.Targetable{
addrs.RootModuleInstance.Child("child2", addrs.NoKey), addrs.RootModuleInstance.Child("child2", addrs.NoKey),
}, },
@ -569,88 +486,89 @@ func TestApplyGraphBuilder_targetModule(t *testing.T) {
} }
const testApplyGraphBuilderStr = ` const testApplyGraphBuilderStr = `
aws_instance.create
provider.aws
aws_instance.other
aws_instance.create
provider.aws
meta.count-boundary (count boundary fixup) meta.count-boundary (count boundary fixup)
aws_instance.create module.child.provisioner.test
aws_instance.other module.child.test_object.create
module.child.aws_instance.create module.child.test_object.other
module.child.aws_instance.other provider.test
module.child.provisioner.exec test_object.create
provider.aws test_object.other
module.child.aws_instance.create module.child.provisioner.test
module.child.provisioner.exec module.child.test_object.create
provider.aws module.child.provisioner.test
module.child.aws_instance.other provider.test
module.child.aws_instance.create module.child.test_object.other
provider.aws module.child.test_object.create
module.child.provisioner.exec provider.test
provider.aws provider.test
provider.aws (close) provider.test (close)
aws_instance.create module.child.test_object.create
aws_instance.other module.child.test_object.other
module.child.aws_instance.create provider.test
module.child.aws_instance.other test_object.create
provider.aws test_object.other
provisioner.exec (close) provisioner.test (close)
module.child.aws_instance.create module.child.test_object.create
root root
meta.count-boundary (count boundary fixup) meta.count-boundary (count boundary fixup)
provider.aws (close) provider.test (close)
provisioner.exec (close) provisioner.test (close)
test_object.create
provider.test
test_object.other
provider.test
test_object.create
` `
const testApplyGraphBuilderDoubleCBDStr = ` const testApplyGraphBuilderDoubleCBDStr = `
aws_instance.A
provider.aws
aws_instance.A (destroy)
aws_instance.A
aws_instance.B
aws_instance.B (destroy)
provider.aws
aws_instance.B
aws_instance.A
provider.aws
aws_instance.B (destroy)
aws_instance.B
provider.aws
meta.count-boundary (count boundary fixup) meta.count-boundary (count boundary fixup)
aws_instance.A provider.test
aws_instance.A (destroy) test_object.A
aws_instance.B test_object.A (destroy)
aws_instance.B (destroy) test_object.B
provider.aws test_object.B (destroy)
provider.aws provider.test
provider.aws (close) provider.test (close)
aws_instance.A provider.test
aws_instance.A (destroy) test_object.A
aws_instance.B test_object.A (destroy)
aws_instance.B (destroy) test_object.B
provider.aws test_object.B (destroy)
root root
meta.count-boundary (count boundary fixup) meta.count-boundary (count boundary fixup)
provider.aws (close) provider.test (close)
test_object.A
provider.test
test_object.A (destroy)
provider.test
test_object.A
test_object.B
test_object.B (destroy)
test_object.B
provider.test
test_object.A
test_object.A (destroy)
test_object.B (destroy)
provider.test
test_object.B
` `
const testApplyGraphBuilderDestroyCountStr = ` const testApplyGraphBuilderDestroyCountStr = `
aws_instance.A[1] (destroy)
provider.aws
aws_instance.B
aws_instance.A[1] (destroy)
provider.aws
meta.count-boundary (count boundary fixup) meta.count-boundary (count boundary fixup)
aws_instance.A[1] (destroy) provider.test
aws_instance.B test_object.A[1] (destroy)
provider.aws test_object.B
provider.aws provider.test
provider.aws (close) provider.test (close)
aws_instance.A[1] (destroy) provider.test
aws_instance.B test_object.A[1] (destroy)
provider.aws test_object.B
root root
meta.count-boundary (count boundary fixup) meta.count-boundary (count boundary fixup)
provider.aws (close) provider.test (close)
test_object.A[1] (destroy)
provider.test
test_object.B
provider.test
test_object.A[1] (destroy)
` `

View File

@ -1,7 +1,7 @@
resource "aws_instance" "create" { resource "test_object" "create" {
provisioner "exec" {} provisioner "test" {}
} }
resource "aws_instance" "other" { resource "test_object" "other" {
value = "${aws_instance.create.id}" test_string = "${test_object.create.test_string}"
} }

View File

@ -2,8 +2,8 @@ module "child" {
source = "./child" source = "./child"
} }
resource "aws_instance" "create" {} resource "test_object" "create" {}
resource "aws_instance" "other" { resource "test_object" "other" {
foo = "${aws_instance.create.bar}" test_string = "${test_object.create.test_string}"
} }

View File

@ -1,7 +1,7 @@
resource "aws_instance" "A" { resource "test_object" "A" {
count = 1 count = 1
} }
resource "aws_instance" "B" { resource "test_object" "B" {
value = ["${aws_instance.A.*.id}"] test_list = test_object.A.*.test_string
} }

View File

@ -1,9 +1,9 @@
resource "aws_instance" "A" { resource "test_object" "A" {
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true
} }
} }
resource "aws_instance" "B" { resource "test_object" "B" {
value = ["${aws_instance.A.*.id}"] test_list = test_object.A.*.test_string
} }

View File

@ -1,11 +1,11 @@
resource "aws_instance" "A" { resource "test_object" "A" {
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true
} }
} }
resource "aws_instance" "B" { resource "test_object" "B" {
value = ["${aws_instance.A.*.id}"] test_list = test_object.A.*.test_string
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true

View File

@ -1,11 +1,9 @@
variable "input" {} variable "input" {}
resource "null_resource" "foo" { resource "test_object" "foo" {
triggers { test_string = var.input
input = "${var.input}"
}
} }
output "output" { output "output" {
value = "${null_resource.foo.id}" value = test_object.foo.id
} }

View File

@ -4,10 +4,10 @@ variable "input" {
module "A" { module "A" {
source = "./A" source = "./A"
input = "${var.input}" input = var.input
} }
module "B" { module "B" {
source = "./A" source = "./A"
input = "${module.A.output}" input = module.A.output
} }

View File

@ -1,3 +1,3 @@
resource "null_resource" "foo" { resource "test_object" "foo" {
provisioner "local" {} provisioner "test" {}
} }

View File

@ -1,11 +1,10 @@
variable "instance_id" { variable "instance_id" {}
}
output "instance_id" { output "instance_id" {
value = "${var.instance_id}" value = "${var.instance_id}"
} }
resource "null_resource" "foo" { resource "test_object" "foo" {
triggers = { triggers = {
instance_id = "${var.instance_id}" instance_id = "${var.instance_id}"
} }

View File

@ -1,2 +1 @@
resource "null_resource" "foo" { resource "test_object" "foo" {}
}

View File

@ -1,8 +1,8 @@
resource "null_resource" "foo" {} resource "test_object" "foo" {}
module "child1" { module "child1" {
source = "./child1" source = "./child1"
instance_id = "${null_resource.foo.id}" instance_id = "${test_object.foo.id}"
} }
module "child2" { module "child2" {