Skip to content

Commit 23a824c

Browse files
additional skipped tests
1 parent 063f0bc commit 23a824c

File tree

2 files changed

+85
-10
lines changed

2 files changed

+85
-10
lines changed

pkg/pf/tests/diff_test/diff_test.go

Lines changed: 85 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package tfbridgetests
22

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

8+
"github.com/hashicorp/terraform-plugin-framework/resource"
79
rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
810
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
911
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
@@ -188,22 +190,96 @@ func TestPFDetailedDiffDynamicType(t *testing.T) {
188190
},
189191
},
190192
}
193+
res := pb.NewResource(pb.NewResourceArgs{
194+
ResourceSchema: attributeSchema,
195+
})
191196

192197
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")})
198+
crosstests.Diff(t, res,
199+
map[string]cty.Value{"key": cty.StringVal("value")},
200+
map[string]cty.Value{"key": cty.StringVal("value")},
201+
)
196202
})
197203

198204
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")})
205+
crosstests.Diff(t, res,
206+
map[string]cty.Value{"key": cty.StringVal("value")},
207+
map[string]cty.Value{"key": cty.StringVal("value1")},
208+
)
202209
})
203210

204211
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))})
212+
crosstests.Diff(t, res,
213+
map[string]cty.Value{"key": cty.NumberVal(big.NewFloat(1))},
214+
map[string]cty.Value{"key": cty.NumberVal(big.NewFloat(1))},
215+
)
216+
})
217+
218+
t.Run("type change", func(t *testing.T) {
219+
// TODO[pulumi/pulumi-terraform-bridge#3078]
220+
t.Skip(`Error converting tftypes.Number<"1"> (value2) at "AttributeName(\"key\")": can't unmarshal tftypes.Number into *string, expected string`)
221+
crosstests.Diff(t, res,
222+
map[string]cty.Value{"key": cty.StringVal("value")},
223+
map[string]cty.Value{"key": cty.NumberVal(big.NewFloat(1))},
224+
)
225+
})
226+
}
227+
228+
func TestPFDetailedDiffDynamicTypeWithMigration(t *testing.T) {
229+
t.Parallel()
230+
// TODO[pulumi/pulumi-terraform-bridge#3078]
231+
t.Skip("DynamicPseudoType is not supported")
232+
233+
attributeSchema := rschema.Schema{
234+
Attributes: map[string]rschema.Attribute{
235+
"key": rschema.DynamicAttribute{
236+
Optional: true,
237+
},
238+
},
239+
}
240+
res1 := pb.NewResource(pb.NewResourceArgs{
241+
ResourceSchema: attributeSchema,
242+
})
243+
244+
schema2 := rschema.Schema{
245+
Attributes: map[string]rschema.Attribute{
246+
"key": rschema.DynamicAttribute{
247+
Optional: true,
248+
},
249+
},
250+
Version: 1,
251+
}
252+
res2 := pb.NewResource(pb.NewResourceArgs{
253+
ResourceSchema: schema2,
254+
UpgradeStateFunc: func(ctx context.Context) map[int64]resource.StateUpgrader {
255+
return map[int64]resource.StateUpgrader{
256+
0: {
257+
PriorSchema: &res1.ResourceSchema,
258+
StateUpgrader: func(ctx context.Context, usr1 resource.UpgradeStateRequest, usr2 *resource.UpgradeStateResponse) {
259+
usr2.State = *usr1.State
260+
},
261+
},
262+
}
263+
},
264+
})
265+
266+
t.Run("no change", func(t *testing.T) {
267+
crosstests.Diff(t, res1,
268+
map[string]cty.Value{"key": cty.StringVal("value")},
269+
map[string]cty.Value{"key": cty.StringVal("value")},
270+
crosstests.DiffProviderUpgradedSchema(
271+
res2,
272+
),
273+
)
274+
})
275+
276+
t.Run("change", func(t *testing.T) {
277+
crosstests.Diff(t, res1,
278+
map[string]cty.Value{"key": cty.StringVal("value")},
279+
map[string]cty.Value{"key": cty.StringVal("value1")},
280+
crosstests.DiffProviderUpgradedSchema(
281+
res2,
282+
),
283+
)
208284
})
209285
}

pkg/pf/tfbridge/resource_state.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ func (p *provider) parseAndUpgradeResourceState(
273273
return nil, fmt.Errorf("[pf/tfbridge] Error calling NewRawState: %w", err)
274274
}
275275

276-
277276
return p.upgradeResourceState(ctx, rh, rawState, parsedMeta.PrivateState, stateVersion)
278277
}
279278

0 commit comments

Comments
 (0)