11package tests
22
33import (
4- "strings"
54 "testing"
65
76 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8- "github.com/hexops/autogold/v2"
97 "github.com/zclconf/go-cty/cty"
10-
11- crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests"
128)
139
1410func TestSDKv2DetailedDiffMap (t * testing.T ) {
@@ -26,7 +22,7 @@ func TestSDKv2DetailedDiffMap(t *testing.T) {
2622 }
2723
2824 var nilVal map [string ]string
29- schemaValueMakerPairs , scenarios := generatePrimitiveSchemaValueMakerPairs (
25+ schemaValueMakerPairs , scenarios := generateBaseTests (
3026 schema .TypeMap , & schema.Schema {Type : schema .TypeString }, ctyMaker ,
3127 map [string ]string {"key" : "val1" }, map [string ]string {"key" : "val2" },
3228 map [string ]string {"key" : "computedVal" }, map [string ]string {"key" : "defaultVal" }, nilVal )
@@ -37,26 +33,5 @@ func TestSDKv2DetailedDiffMap(t *testing.T) {
3733 changeValue : ref (map [string ]string {"key2" : "val1" }),
3834 })
3935
40- for _ , schemaValueMakerPair := range schemaValueMakerPairs {
41- t .Run (schemaValueMakerPair .name , func (t * testing.T ) {
42- t .Parallel ()
43- for _ , scenario := range scenarios {
44- t .Run (scenario .name , func (t * testing.T ) {
45- if strings .Contains (schemaValueMakerPair .name , "required" ) &&
46- (scenario .initialValue == nil || scenario .changeValue == nil ) {
47- t .Skip ("Required fields cannot be unset" )
48- }
49- t .Parallel ()
50- diff := crosstests .Diff (t , & schemaValueMakerPair .schema , schemaValueMakerPair .valueMaker (scenario .initialValue ), schemaValueMakerPair .valueMaker (scenario .changeValue ))
51- autogold .ExpectFile (t , testOutput {
52- initialValue : scenario .initialValue ,
53- changeValue : scenario .changeValue ,
54- tfOut : diff .TFOut ,
55- pulumiOut : diff .PulumiOut ,
56- detailedDiff : diff .PulumiDiff .DetailedDiff ,
57- })
58- })
59- }
60- })
61- }
36+ runSDKv2TestMatrix (t , schemaValueMakerPairs , scenarios )
6237}
0 commit comments