mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-02 04:07:22 -06:00
46b4c27dbe
Terraform now handles any actual "diffing" of resource, and the existing Diff functions are only used to shim the schema.Provider to the new methods. Since terraform is handling what used to be the Diff, the provider now should not modify the diff based on RequiresNew due to it interfering with the ignore_changes handling.
33 lines
658 B
Go
33 lines
658 B
Go
package schema
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/config"
|
|
"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 {
|
|
t.Helper()
|
|
|
|
c, err := config.NewRawConfig(raw)
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
sm := schemaMap(schema)
|
|
diff, err := sm.Diff(nil, terraform.NewResourceConfig(c), nil, nil, true)
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
result, err := sm.Data(nil, diff)
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
|
|
return result
|
|
}
|