Skip to content

Commit 3a7afd5

Browse files
committed
fixup! fixup! fixup! Use ImportPlanVerify
1 parent eb4679f commit 3a7afd5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/teststep/verify_import_plan.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ func VerifyImportPlan(plan *tfjson.Plan, state *terraform.State) error {
4848
if !ok {
4949
panic(fmt.Sprintf("unexpected type %T", v))
5050
}
51+
5152
oldResource := oldResources[rc.Address]
5253
if oldResource == nil {
5354
// does this matter?
5455
return fmt.Errorf("importing resource %s: expected resource %s to exist in known state", rc.Address, rc.Change.Importing.ID)
5556
}
57+
5658
attr, ok := oldResource.Primary.Attributes[k]
59+
if !ok {
60+
return fmt.Errorf("importing resource %s: expected %s in known state to exist", rc.Address, k)
61+
}
5762
if attr != vs {
5863
return fmt.Errorf("importing resource %s: expected %s in known state to be %q, got %q", rc.Address, k, oldResource.Primary.Attributes[k], vs)
5964
}

0 commit comments

Comments
 (0)