terraform-provider-gitea/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/testing.go

30 lines
634 B
Go
Raw Normal View History

2022-04-03 04:07:16 +00:00
package schema
import (
"context"
2022-04-03 04:07:16 +00:00
testing "github.com/mitchellh/go-testing-interface"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
2022-04-03 04:07:16 +00:00
)
// TestResourceDataRaw creates a ResourceData from a raw configuration map.
func TestResourceDataRaw(t testing.T, schema map[string]*Schema, raw map[string]interface{}) *ResourceData {
2022-04-03 04:07:16 +00:00
t.Helper()
c := terraform.NewResourceConfigRaw(raw)
sm := schemaMap(schema)
diff, err := sm.Diff(context.Background(), nil, c, nil, nil, true)
2022-04-03 04:07:16 +00: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
}