Skip to content

Commit

Permalink
Fix spurious diff from timeouts.
Browse files Browse the repository at this point in the history
When testing and verifying that the imported state matches the applied
state, we're seeing some resources report that the number of elements in
the `timeouts` map don't match between the two states. Apparently, any
timeouts set in the config are added to state during _import_, but
aren't during a regular apply.

To avoid returning this incorrectly as a diff, we're just not going to
verify that.
  • Loading branch information
paddycarver committed Sep 11, 2020
1 parent a8e5eaf commit cf5a77d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions helper/resource/testing_new_import_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,26 @@ func testStepNewImportState(t testing.T, c TestCase, helper *tftest.Helper, wd *
}
}

// timeouts are only _sometimes_ added to state. To
// account for this, just don't compare timeouts at
// all.
for k := range actual {
if strings.HasPrefix(k, "timeouts.") {
delete(actual, k)
}
if k == "timeouts" {
delete(actual, k)
}
}
for k := range expected {
if strings.HasPrefix(k, "timeouts.") {
delete(expected, k)
}
if k == "timeouts" {
delete(expected, k)
}
}

if !reflect.DeepEqual(actual, expected) {
// Determine only the different attributes
for k, v := range expected {
Expand Down

0 comments on commit cf5a77d

Please sign in to comment.