Skip to content

Commit b65ddd5

Browse files
Fix PF dynamic type diff error
1 parent d1e4da9 commit b65ddd5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pkg/pf/tests/diff_test/diff_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tfbridgetests
22

33
import (
4+
"math/big"
45
"testing"
56

67
rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
@@ -176,3 +177,39 @@ func TestPFDetailedDiffStringAttribute(t *testing.T) {
176177
})
177178
}
178179
}
180+
181+
func TestPFDetailedDiffDynamicType(t *testing.T) {
182+
t.Parallel()
183+
184+
attributeSchema := rschema.Schema{
185+
Attributes: map[string]rschema.Attribute{
186+
"key": rschema.DynamicAttribute{
187+
Optional: true,
188+
},
189+
},
190+
}
191+
192+
t.Run("no change", func(t *testing.T) {
193+
crosstests.Diff(t, pb.NewResource(pb.NewResourceArgs{
194+
ResourceSchema: attributeSchema,
195+
}), map[string]cty.Value{"key": cty.StringVal("value")}, map[string]cty.Value{"key": cty.StringVal("value")})
196+
})
197+
198+
t.Run("change", func(t *testing.T) {
199+
crosstests.Diff(t, pb.NewResource(pb.NewResourceArgs{
200+
ResourceSchema: attributeSchema,
201+
}), map[string]cty.Value{"key": cty.StringVal("value")}, map[string]cty.Value{"key": cty.StringVal("value1")})
202+
})
203+
204+
t.Run("int no change", func(t *testing.T) {
205+
crosstests.Diff(t, pb.NewResource(pb.NewResourceArgs{
206+
ResourceSchema: attributeSchema,
207+
}), map[string]cty.Value{"key": cty.NumberVal(big.NewFloat(1))}, map[string]cty.Value{"key": cty.NumberVal(big.NewFloat(1))})
208+
})
209+
210+
t.Run("type change", func(t *testing.T) {
211+
crosstests.Diff(t, pb.NewResource(pb.NewResourceArgs{
212+
ResourceSchema: attributeSchema,
213+
}), map[string]cty.Value{"key": cty.StringVal("value")}, map[string]cty.Value{"key": cty.NumberVal(big.NewFloat(1))})
214+
})
215+
}

0 commit comments

Comments
 (0)