2016-12-23 02:05:45 +01:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestResourceDataRaw creates a ResourceData from a raw configuration map.
|
|
|
|
func TestResourceDataRaw(
|
|
|
|
t *testing.T, schema map[string]*Schema, raw map[string]interface{}) *ResourceData {
|
2017-08-26 01:23:47 +02:00
|
|
|
t.Helper()
|
|
|
|
|
2019-07-31 06:05:09 +02:00
|
|
|
c := terraform.NewResourceConfigRaw(raw)
|
2016-12-23 02:05:45 +01:00
|
|
|
|
|
|
|
sm := schemaMap(schema)
|
2019-07-31 06:05:09 +02:00
|
|
|
diff, err := sm.Diff(nil, c, nil, nil, true)
|
2016-12-23 02:05:45 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := sm.Data(nil, diff)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|