Skip to content

Commit 151f59e

Browse files
authored
add TestResourceDataWithIdentityRaw test helper (#1475)
Resolves #1464
1 parent 34b8271 commit 151f59e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

helper/schema/testing.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,20 @@ func TestResourceDataRaw(t testing.T, schema map[string]*Schema, raw map[string]
3030

3131
return result
3232
}
33+
34+
// TestResourceDataWithIdentityRaw creates a ResourceData with an identity from a raw identity map.
35+
func TestResourceDataWithIdentityRaw(t testing.T, schema map[string]*Schema, identitySchema map[string]*Schema, raw map[string]string) *ResourceData {
36+
t.Helper()
37+
38+
sm := schemaMapWithIdentity{schema, identitySchema}
39+
state := terraform.InstanceState{
40+
Identity: raw,
41+
}
42+
43+
result, err := sm.Data(&state, nil)
44+
if err != nil {
45+
t.Fatalf("err: %s", err)
46+
}
47+
48+
return result
49+
}

0 commit comments

Comments
 (0)