@@ -1093,6 +1093,62 @@ func TestPFUpgrade_Downgrading(t *testing.T) {
10931093 })
10941094}
10951095
1096+ // Test when a dynamic pseudo type value is being sent through a state upgrader.
1097+ func TestPFUpgrade_DynamicPseudoType (t * testing.T ) {
1098+ t .Parallel ()
1099+ ct .SkipUnlessLinux (t )
1100+ //skipUnlessDeltasEnabled(t)
1101+
1102+ resourceBefore := pb .NewResource (pb.NewResourceArgs {
1103+ ResourceSchema : schema.Schema {
1104+ Attributes : map [string ]schema.Attribute {
1105+ "dyn" : schema.DynamicAttribute {Optional : true },
1106+ },
1107+ },
1108+ })
1109+
1110+ resourceAfter := pb .NewResource (pb.NewResourceArgs {
1111+ UpgradeStateFunc : func (ctx context.Context ) map [int64 ]resource.StateUpgrader {
1112+ return map [int64 ]resource.StateUpgrader {
1113+ 0 : {
1114+ PriorSchema : & resourceBefore .ResourceSchema ,
1115+ StateUpgrader : ct .NopUpgrader ,
1116+ },
1117+ }
1118+ },
1119+ ResourceSchema : schema.Schema {
1120+ Attributes : map [string ]schema.Attribute {
1121+ "dyn" : schema.DynamicAttribute {Optional : true },
1122+ },
1123+ Version : 1 ,
1124+ },
1125+ })
1126+
1127+ tfInputsBefore := cty .ObjectVal (map [string ]cty.Value {"dyn" : cty .StringVal ("str" )})
1128+ tfInputsAfter := cty .ObjectVal (map [string ]cty.Value {"dyn" : cty .NumberIntVal (42 )})
1129+ pmBefore := presource .NewPropertyMapFromMap (map [string ]any {"dyn" : "str" })
1130+ pmAfter := presource .NewPropertyMapFromMap (map [string ]any {"dyn" : 42 })
1131+
1132+ testCase := ct.UpgradeStateTestCase {
1133+ Resource1 : & resourceBefore ,
1134+ Resource2 : & resourceAfter ,
1135+ Inputs1 : tfInputsBefore ,
1136+ InputsMap1 : pmBefore ,
1137+ Inputs2 : tfInputsAfter ,
1138+ InputsMap2 : pmAfter ,
1139+ //ExpectedRawStateType: resourceBeforeAndAfter.ResourceSchema.Type().TerraformType(context.Background()),
1140+ SkipPulumi : "TODO" ,
1141+ }
1142+
1143+ _ = testCase .Run (t )
1144+
1145+ // autogold.Expect(map[apitype.OpType]int{apitype.OpType("same"): 2}).Equal(t, result.PulumiPreviewResult.ChangeSummary)
1146+ // autogold.Expect(&map[string]int{"same": 2}).Equal(t, result.PulumiUpResult.Summary.ResourceChanges)
1147+
1148+ // autogold.Expect([]ct.UpgradeStateTrace{}).Equal(t, result.PulumiUpgrades)
1149+ // autogold.Expect([]ct.UpgradeStateTrace{}).Equal(t, result.TFUpgrades)
1150+ }
1151+
10961152func skipUnlessDeltasEnabled (t * testing.T ) {
10971153 if d , ok := os .LookupEnv ("PULUMI_RAW_STATE_DELTA_ENABLED" ); ! ok || ! cmdutil .IsTruthy (d ) {
10981154 t .Skip ("This test requires PULUMI_RAW_STATE_DELTA_ENABLED=true environment" )
0 commit comments