@@ -927,6 +927,116 @@ func TestServerUpdateResource(t *testing.T) {
927927 Private : testEmptyPrivate ,
928928 },
929929 },
930+ "response-new-identity-nil" : {
931+ server : & fwserver.Server {
932+ Provider : & testprovider.Provider {},
933+ },
934+ request : & fwserver.UpdateResourceRequest {
935+ PlannedState : & tfsdk.Plan {
936+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
937+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
938+ "test_required" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
939+ }),
940+ Schema : testSchema ,
941+ },
942+ PlannedIdentity : & tfsdk.ResourceIdentity {
943+ Raw : tftypes .NewValue (testIdentityType , nil ),
944+ Schema : testIdentitySchema ,
945+ },
946+ IdentitySchema : testIdentitySchema ,
947+ ResourceSchema : testSchema ,
948+ Resource : & testprovider.ResourceWithIdentity {
949+ Resource : & testprovider.Resource {
950+ UpdateMethod : func (ctx context.Context , req resource.UpdateRequest , resp * resource.UpdateResponse ) {
951+ var data testSchemaData
952+ resp .Diagnostics .Append (req .Plan .Get (ctx , & data )... )
953+ resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
954+
955+ resp .Identity .Raw = tftypes .NewValue (testIdentityType , nil )
956+
957+ },
958+ },
959+ },
960+ },
961+ expectedResponse : & fwserver.UpdateResourceResponse {
962+ Diagnostics : []diag.Diagnostic {
963+ diag .NewErrorDiagnostic (
964+ "Missing Resource Identity After Update" ,
965+ "The Terraform Provider unexpectedly returned no resource identity data after having no errors in the resource update. This is always an issue in the Terraform Provider and should be reported to the provider developers." ,
966+ ),
967+ },
968+ NewIdentity : & tfsdk.ResourceIdentity {
969+ Raw : tftypes .NewValue (testIdentityType , nil ),
970+ Schema : testIdentitySchema ,
971+ },
972+ NewState : & tfsdk.State {
973+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
974+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
975+ "test_required" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
976+ }),
977+ Schema : testSchema ,
978+ },
979+ Private : testEmptyPrivate ,
980+ },
981+ },
982+ "response-new-identity-null" : {
983+ server : & fwserver.Server {
984+ Provider : & testprovider.Provider {},
985+ },
986+ request : & fwserver.UpdateResourceRequest {
987+ PlannedState : & tfsdk.Plan {
988+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
989+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
990+ "test_required" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
991+ }),
992+ Schema : testSchema ,
993+ },
994+ PlannedIdentity : & tfsdk.ResourceIdentity {
995+ Raw : tftypes .NewValue (testIdentityType , map [string ]tftypes.Value {
996+ "test_id" : tftypes .NewValue (tftypes .String , nil ),
997+ }),
998+ Schema : testIdentitySchema ,
999+ },
1000+ IdentitySchema : testIdentitySchema ,
1001+ ResourceSchema : testSchema ,
1002+ Resource : & testprovider.ResourceWithIdentity {
1003+ Resource : & testprovider.Resource {
1004+ UpdateMethod : func (ctx context.Context , req resource.UpdateRequest , resp * resource.UpdateResponse ) {
1005+ var data testSchemaData
1006+ resp .Diagnostics .Append (req .Plan .Get (ctx , & data )... )
1007+ resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
1008+
1009+ var identityData testIdentitySchemaData
1010+ resp .Diagnostics .Append (req .Identity .Get (ctx , & identityData )... )
1011+ resp .Diagnostics .Append (resp .Identity .Set (ctx , & identityData )... )
1012+
1013+ },
1014+ },
1015+ },
1016+ },
1017+ expectedResponse : & fwserver.UpdateResourceResponse {
1018+ Diagnostics : []diag.Diagnostic {
1019+ diag .NewErrorDiagnostic (
1020+ "Missing Resource Identity After Update" ,
1021+ "The Terraform Provider unexpectedly returned no resource identity data after having no errors in the resource update. This is always an issue in the Terraform Provider and should be reported to the provider developers." ,
1022+ ),
1023+ },
1024+ NewIdentity : & tfsdk.ResourceIdentity {
1025+ Raw : tftypes .NewValue (testIdentityType , map [string ]tftypes.Value {
1026+ "test_id" : tftypes .NewValue (tftypes .String , nil ),
1027+ }),
1028+ Schema : testIdentitySchema ,
1029+ },
1030+ NewState : & tfsdk.State {
1031+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
1032+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
1033+ "test_required" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
1034+ }),
1035+ Schema : testSchema ,
1036+ },
1037+ Private : testEmptyPrivate ,
1038+ },
1039+ },
9301040 "response-newstate-semantic-equality" : {
9311041 server : & fwserver.Server {
9321042 Provider : & testprovider.Provider {},
0 commit comments