github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/testing.go (about) 1 package schema 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform-plugin-sdk/terraform" 7 ) 8 9 // TestResourceDataRaw creates a ResourceData from a raw configuration map. 10 func TestResourceDataRaw( 11 t *testing.T, schema map[string]*Schema, raw map[string]interface{}) *ResourceData { 12 t.Helper() 13 14 c := terraform.NewResourceConfigRaw(raw) 15 16 sm := schemaMap(schema) 17 diff, err := sm.Diff(nil, c, nil, nil, true) 18 if err != nil { 19 t.Fatalf("err: %s", err) 20 } 21 22 result, err := sm.Data(nil, diff) 23 if err != nil { 24 t.Fatalf("err: %s", err) 25 } 26 27 return result 28 }