Skip to content

Commit fe3a90e

Browse files
toppercodesampagent
andcommitted
Fix dashboard import check UID capture
Amp-Thread-ID: https://ampcode.com/threads/T-019cb38a-d07d-75bf-9176-bc810a11c485 Co-authored-by: Amp <amp@ampcode.com>
1 parent 343e27e commit fe3a90e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

axiom/resource_dashboard_integration_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestAccAxiomDashboardResource_WithProvidedUID(t *testing.T) {
6363
ImportState: true,
6464
ImportStateVerify: true,
6565
ImportStateId: uid,
66-
ImportStateCheck: testAccCheckImportedDashboardState(uid, updatedName, nil),
66+
ImportStateCheck: testAccCheckImportedDashboardState(func() string { return uid }, updatedName, nil),
6767
},
6868
},
6969
})
@@ -130,7 +130,7 @@ func TestAccAxiomDashboardResource_ServerGeneratedUID(t *testing.T) {
130130
return generatedUID, nil
131131
},
132132
ImportStateVerify: true,
133-
ImportStateCheck: testAccCheckImportedDashboardState(generatedUID, updatedName, func(v string) error {
133+
ImportStateCheck: testAccCheckImportedDashboardState(func() string { return generatedUID }, updatedName, func(v string) error {
134134
if v != "false" {
135135
return fmt.Errorf("expected imported overwrite to default to false, got %q", v)
136136
}
@@ -275,15 +275,16 @@ func testAccCaptureDashboardUID(resourceName string, out *string) resource.TestC
275275
}
276276
}
277277

278-
func testAccCheckImportedDashboardState(expectedUID, expectedName string, overwriteCheck func(string) error) resource.ImportStateCheckFunc {
278+
func testAccCheckImportedDashboardState(expectedUID func() string, expectedName string, overwriteCheck func(string) error) resource.ImportStateCheckFunc {
279279
return func(states []*terraform.InstanceState) error {
280280
if len(states) != 1 {
281281
return fmt.Errorf("expected exactly one imported instance state, got %d", len(states))
282282
}
283283

284284
attrs := states[0].Attributes
285-
if attrs["uid"] != expectedUID {
286-
return fmt.Errorf("expected imported uid %q, got %q", expectedUID, attrs["uid"])
285+
wantUID := expectedUID()
286+
if attrs["uid"] != wantUID {
287+
return fmt.Errorf("expected imported uid %q, got %q", wantUID, attrs["uid"])
287288
}
288289

289290
dashboardJSON := attrs["dashboard"]

0 commit comments

Comments
 (0)