@@ -1862,6 +1862,76 @@ func TestServerApplyResourceChange(t *testing.T) {
18621862 Private : testEmptyPrivate ,
18631863 },
18641864 },
1865+ "update-valid-response-mutable-identity-newidentity-changes" : {
1866+ server : & fwserver.Server {
1867+ Provider : & testprovider.Provider {},
1868+ },
1869+ request : & fwserver.ApplyResourceChangeRequest {
1870+ Config : & tfsdk.Config {
1871+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
1872+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
1873+ "test_required" : tftypes .NewValue (tftypes .String , "test-new-value" ),
1874+ }),
1875+ Schema : testSchema ,
1876+ },
1877+ PlannedState : & tfsdk.Plan {
1878+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
1879+ "test_computed" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
1880+ "test_required" : tftypes .NewValue (tftypes .String , "test-new-value" ),
1881+ }),
1882+ Schema : testSchema ,
1883+ },
1884+ PlannedIdentity : & tfsdk.ResourceIdentity {
1885+ Raw : tftypes .NewValue (testIdentityType , map [string ]tftypes.Value {
1886+ "test_id" : tftypes .NewValue (tftypes .String , "id-123" ),
1887+ }),
1888+ Schema : testIdentitySchema ,
1889+ },
1890+ PriorState : & tfsdk.State {
1891+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
1892+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
1893+ "test_required" : tftypes .NewValue (tftypes .String , "test-old-value" ),
1894+ }),
1895+ Schema : testSchema ,
1896+ },
1897+ IdentitySchema : testIdentitySchema ,
1898+ ResourceSchema : testSchema ,
1899+ ResourceBehavior : resource.ResourceBehavior {
1900+ MutableIdentity : true ,
1901+ },
1902+ Resource : & testprovider.ResourceWithIdentity {
1903+ Resource : & testprovider.Resource {
1904+ CreateMethod : func (_ context.Context , _ resource.CreateRequest , resp * resource.CreateResponse ) {
1905+ resp .Diagnostics .AddError ("Unexpected Method Call" , "Expected: Update, Got: Create" )
1906+ },
1907+ DeleteMethod : func (_ context.Context , _ resource.DeleteRequest , resp * resource.DeleteResponse ) {
1908+ resp .Diagnostics .AddError ("Unexpected Method Call" , "Expected: Update, Got: Delete" )
1909+ },
1910+ UpdateMethod : func (ctx context.Context , req resource.UpdateRequest , resp * resource.UpdateResponse ) {
1911+ resp .Diagnostics .Append (resp .Identity .Set (ctx , testIdentitySchemaData {
1912+ TestID : types .StringValue ("new-id-123" ),
1913+ })... )
1914+ },
1915+ },
1916+ },
1917+ },
1918+ expectedResponse : & fwserver.ApplyResourceChangeResponse {
1919+ NewIdentity : & tfsdk.ResourceIdentity {
1920+ Raw : tftypes .NewValue (testIdentityType , map [string ]tftypes.Value {
1921+ "test_id" : tftypes .NewValue (tftypes .String , "new-id-123" ),
1922+ }),
1923+ Schema : testIdentitySchema ,
1924+ },
1925+ NewState : & tfsdk.State {
1926+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
1927+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
1928+ "test_required" : tftypes .NewValue (tftypes .String , "test-old-value" ),
1929+ }),
1930+ Schema : testSchema ,
1931+ },
1932+ Private : testEmptyPrivate ,
1933+ },
1934+ },
18651935 "update-response-newstate-null" : {
18661936 server : & fwserver.Server {
18671937 Provider : & testprovider.Provider {},
0 commit comments