@@ -48,6 +48,12 @@ func TestServerMoveResourceState(t *testing.T) {
4848 },
4949 }
5050
51+ testIdentityType := tftypes.Object {
52+ AttributeTypes : map [string ]tftypes.Type {
53+ "test_id" : tftypes .String ,
54+ },
55+ }
56+
5157 testCases := map [string ]struct {
5258 server * Server
5359 request * tfprotov5.MoveResourceStateRequest
@@ -508,7 +514,15 @@ func TestServerMoveResourceState(t *testing.T) {
508514 resp .Diagnostics .AddError ("Unexpected req.SourceRawState difference" , diff )
509515 }
510516
511- resp .Diagnostics .Append (resp .TargetIdentity .SetAttribute (ctx , path .Root ("test_id" ), "test_id_value" )... )
517+ expectedSourceIdentity := testNewTfprotov6RawState (t , map [string ]interface {}{
518+ "test_id" : "test-id-value" ,
519+ })
520+
521+ if diff := cmp .Diff (req .SourceIdentity , expectedSourceIdentity ); diff != "" {
522+ resp .Diagnostics .AddError ("Unexpected req.SourceIdentity difference" , diff )
523+ }
524+
525+ resp .Diagnostics .Append (resp .TargetIdentity .SetAttribute (ctx , path .Root ("test_id" ), "test-id-value" )... )
512526
513527 // Prevent missing implementation error, the values do not matter except for response assertion
514528 resp .Diagnostics .Append (resp .TargetState .SetAttribute (ctx , path .Root ("id" ), "test-id-value" )... )
@@ -538,7 +552,7 @@ func TestServerMoveResourceState(t *testing.T) {
538552 TargetTypeName : "test_resource" ,
539553 },
540554 expectedResponse : & tfprotov5.MoveResourceStateResponse {
541- TargetIdentity : & tfprotov5.ResourceIdentityData {IdentityData : testNewDynamicValue (t , schemaType , map [string ]tftypes.Value {
555+ TargetIdentity : & tfprotov5.ResourceIdentityData {IdentityData : testNewDynamicValue (t , testIdentityType , map [string ]tftypes.Value {
542556 "test_id" : tftypes .NewValue (tftypes .String , "test-id-value" ),
543557 })},
544558 TargetState : testNewDynamicValue (t , schemaType , map [string ]tftypes.Value {
@@ -860,7 +874,7 @@ func TestServerMoveResourceState(t *testing.T) {
860874 return []resource.StateMover {
861875 {
862876 StateMover : func (_ context.Context , req resource.MoveStateRequest , resp * resource.MoveStateResponse ) {
863- resp .Diagnostics .Append (resp .TargetIdentity .SetAttribute (ctx , path .Root ("test_id" ), "test_id_value " )... )
877+ resp .Diagnostics .Append (resp .TargetIdentity .SetAttribute (ctx , path .Root ("test_id" ), "test-id-value " )... )
864878 resp .Diagnostics .Append (resp .TargetState .SetAttribute (ctx , path .Root ("id" ), "test-id-value" )... )
865879 resp .Diagnostics .Append (resp .TargetState .SetAttribute (ctx , path .Root ("required_attribute" ), "true" )... )
866880 },
@@ -893,7 +907,7 @@ func TestServerMoveResourceState(t *testing.T) {
893907 "optional_attribute" : tftypes .NewValue (tftypes .String , nil ),
894908 "required_attribute" : tftypes .NewValue (tftypes .String , "true" ),
895909 }),
896- TargetIdentity : & tfprotov5.ResourceIdentityData {IdentityData : testNewDynamicValue (t , schemaType , map [string ]tftypes.Value {
910+ TargetIdentity : & tfprotov5.ResourceIdentityData {IdentityData : testNewDynamicValue (t , testIdentityType , map [string ]tftypes.Value {
897911 "test_id" : tftypes .NewValue (tftypes .String , "test-id-value" ),
898912 })},
899913 },
0 commit comments