core: Fix TestContext2Apply_resourceDependsOnModuleStateOnly

This test was depending on InstanceInfo.HumanId, which is not something
any real providers use and therefore not something our shims from new to
old provider API supports.

Instead, we'll give each of the instances a different id and use that
to distinguish them for tracking apply order.
This commit is contained in:
Martin Atkins 2018-09-11 17:04:57 -07:00
parent edc0ce6333
commit f0b7d01072
1 changed files with 4 additions and 6 deletions

View File

@ -295,7 +295,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
"aws_instance.a": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
ID: "parent",
},
Dependencies: []string{"module.child"},
Provider: "provider.aws",
@ -308,7 +308,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
"aws_instance.child": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
ID: "child",
},
Provider: "provider.aws",
},
@ -326,8 +326,8 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
info *InstanceInfo,
is *InstanceState,
id *InstanceDiff) (*InstanceState, error) {
if info.HumanId() == "aws_instance.a" {
if is.ID == "parent" {
// make the dep slower than the parent
time.Sleep(50 * time.Millisecond)
@ -358,9 +358,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
}
state, diags := ctx.Apply()
if diags.HasErrors() {
t.Fatalf("diags: %s", diags.Err())
}
assertNoErrors(t, diags)
if !reflect.DeepEqual(order, []string{"child", "parent"}) {
t.Fatal("resources applied out of order")