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