@@ -589,6 +589,24 @@ func TestServerPlanResourceChange(t *testing.T) {
589589 },
590590 }
591591
592+ type testMultiIdentitySchemaData struct {
593+ TestAttrA types.String `tfsdk:"test_attr_a"`
594+ TestAttrB types.Int64 `tfsdk:"test_attr_b"`
595+ }
596+
597+ testMultiAttrIdentitySchema := identityschema.Schema {
598+ Attributes : map [string ]identityschema.Attribute {
599+ "test_attr_a" : identityschema.StringAttribute {
600+ RequiredForImport : true ,
601+ },
602+ "test_attr_b" : identityschema.Int64Attribute {
603+ OptionalForImport : true ,
604+ },
605+ },
606+ }
607+
608+ testMultiAttrIdentityType := testMultiAttrIdentitySchema .Type ().TerraformType (context .Background ())
609+
592610 testSchemaWriteOnly := schema.Schema {
593611 Attributes : map [string ]schema.Attribute {
594612 "test_computed" : schema.StringAttribute {
@@ -6722,6 +6740,77 @@ func TestServerPlanResourceChange(t *testing.T) {
67226740 PlannedPrivate : testEmptyPrivate ,
67236741 },
67246742 },
6743+ "update-resourcewithmodifyplan-empty-prioridentity-plannedidentity-changed" : {
6744+ server : & fwserver.Server {
6745+ Provider : & testprovider.Provider {},
6746+ },
6747+ request : & fwserver.PlanResourceChangeRequest {
6748+ Config : & tfsdk.Config {
6749+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6750+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
6751+ "test_required" : tftypes .NewValue (tftypes .String , "test-new-value" ),
6752+ }),
6753+ Schema : testSchema ,
6754+ },
6755+ ProposedNewState : & tfsdk.Plan {
6756+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6757+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
6758+ "test_required" : tftypes .NewValue (tftypes .String , "test-new-value" ),
6759+ }),
6760+ Schema : testSchema ,
6761+ },
6762+ PriorState : & tfsdk.State {
6763+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6764+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
6765+ "test_required" : tftypes .NewValue (tftypes .String , "test-old-value" ),
6766+ }),
6767+ Schema : testSchema ,
6768+ },
6769+ PriorIdentity : & tfsdk.ResourceIdentity {
6770+ Raw : tftypes .NewValue (testMultiAttrIdentityType , map [string ]tftypes.Value {
6771+ "test_attr_a" : tftypes .NewValue (tftypes .String , nil ),
6772+ "test_attr_b" : tftypes .NewValue (tftypes .Number , nil ),
6773+ }),
6774+ Schema : testMultiAttrIdentitySchema ,
6775+ },
6776+ IdentitySchema : testMultiAttrIdentitySchema ,
6777+ ResourceSchema : testSchema ,
6778+ Resource : & testprovider.ResourceWithIdentityAndModifyPlan {
6779+ ModifyPlanMethod : func (ctx context.Context , req resource.ModifyPlanRequest , resp * resource.ModifyPlanResponse ) {
6780+ var data testSchemaData
6781+ resp .Diagnostics .Append (req .Plan .Get (ctx , & data )... )
6782+ data .TestComputed = types .StringValue ("test-plannedstate-value" )
6783+ resp .Diagnostics .Append (resp .Plan .Set (ctx , & data )... )
6784+
6785+ var identityData testMultiIdentitySchemaData
6786+ resp .Diagnostics .Append (req .Identity .Get (ctx , & identityData )... )
6787+ identityData .TestAttrA = types .StringValue ("new value" )
6788+ identityData .TestAttrB = types .Int64Value (20 )
6789+ resp .Diagnostics .Append (resp .Identity .Set (ctx , & identityData )... )
6790+ },
6791+ IdentitySchemaMethod : func (ctx context.Context , req resource.IdentitySchemaRequest , resp * resource.IdentitySchemaResponse ) {
6792+ resp .IdentitySchema = testMultiAttrIdentitySchema
6793+ },
6794+ },
6795+ },
6796+ expectedResponse : & fwserver.PlanResourceChangeResponse {
6797+ PlannedIdentity : & tfsdk.ResourceIdentity {
6798+ Raw : tftypes .NewValue (testMultiAttrIdentityType , map [string ]tftypes.Value {
6799+ "test_attr_a" : tftypes .NewValue (tftypes .String , "new value" ),
6800+ "test_attr_b" : tftypes .NewValue (tftypes .Number , 20 ),
6801+ }),
6802+ Schema : testMultiAttrIdentitySchema ,
6803+ },
6804+ PlannedState : & tfsdk.State {
6805+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6806+ "test_computed" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
6807+ "test_required" : tftypes .NewValue (tftypes .String , "test-new-value" ),
6808+ }),
6809+ Schema : testSchema ,
6810+ },
6811+ PlannedPrivate : testEmptyPrivate ,
6812+ },
6813+ },
67256814 "update-resourcewithmodifyplan-invalid-response-plannedidentity-changed" : {
67266815 server : & fwserver.Server {
67276816 Provider : & testprovider.Provider {},
0 commit comments