@@ -48,6 +48,12 @@ func TestServerMoveResourceState(t *testing.T) {
48
48
},
49
49
}
50
50
51
+ testIdentityType := tftypes.Object {
52
+ AttributeTypes : map [string ]tftypes.Type {
53
+ "test_id" : tftypes .String ,
54
+ },
55
+ }
56
+
51
57
testCases := map [string ]struct {
52
58
server * Server
53
59
request * tfprotov5.MoveResourceStateRequest
@@ -508,7 +514,15 @@ func TestServerMoveResourceState(t *testing.T) {
508
514
resp .Diagnostics .AddError ("Unexpected req.SourceRawState difference" , diff )
509
515
}
510
516
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" )... )
512
526
513
527
// Prevent missing implementation error, the values do not matter except for response assertion
514
528
resp .Diagnostics .Append (resp .TargetState .SetAttribute (ctx , path .Root ("id" ), "test-id-value" )... )
@@ -538,7 +552,7 @@ func TestServerMoveResourceState(t *testing.T) {
538
552
TargetTypeName : "test_resource" ,
539
553
},
540
554
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 {
542
556
"test_id" : tftypes .NewValue (tftypes .String , "test-id-value" ),
543
557
})},
544
558
TargetState : testNewDynamicValue (t , schemaType , map [string ]tftypes.Value {
@@ -860,7 +874,7 @@ func TestServerMoveResourceState(t *testing.T) {
860
874
return []resource.StateMover {
861
875
{
862
876
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 " )... )
864
878
resp .Diagnostics .Append (resp .TargetState .SetAttribute (ctx , path .Root ("id" ), "test-id-value" )... )
865
879
resp .Diagnostics .Append (resp .TargetState .SetAttribute (ctx , path .Root ("required_attribute" ), "true" )... )
866
880
},
@@ -893,7 +907,7 @@ func TestServerMoveResourceState(t *testing.T) {
893
907
"optional_attribute" : tftypes .NewValue (tftypes .String , nil ),
894
908
"required_attribute" : tftypes .NewValue (tftypes .String , "true" ),
895
909
}),
896
- TargetIdentity : & tfprotov5.ResourceIdentityData {IdentityData : testNewDynamicValue (t , schemaType , map [string ]tftypes.Value {
910
+ TargetIdentity : & tfprotov5.ResourceIdentityData {IdentityData : testNewDynamicValue (t , testIdentityType , map [string ]tftypes.Value {
897
911
"test_id" : tftypes .NewValue (tftypes .String , "test-id-value" ),
898
912
})},
899
913
},
0 commit comments