Skip to content

Commit cf5a77d

Browse files
paddycarverPaddy
authored andcommitted
Fix spurious diff from timeouts.
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.
1 parent a8e5eaf commit cf5a77d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

helper/resource/testing_new_import_state.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,26 @@ func testStepNewImportState(t testing.T, c TestCase, helper *tftest.Helper, wd *
171171
}
172172
}
173173

174+
// timeouts are only _sometimes_ added to state. To
175+
// account for this, just don't compare timeouts at
176+
// all.
177+
for k := range actual {
178+
if strings.HasPrefix(k, "timeouts.") {
179+
delete(actual, k)
180+
}
181+
if k == "timeouts" {
182+
delete(actual, k)
183+
}
184+
}
185+
for k := range expected {
186+
if strings.HasPrefix(k, "timeouts.") {
187+
delete(expected, k)
188+
}
189+
if k == "timeouts" {
190+
delete(expected, k)
191+
}
192+
}
193+
174194
if !reflect.DeepEqual(actual, expected) {
175195
// Determine only the different attributes
176196
for k, v := range expected {

0 commit comments

Comments
 (0)