@@ -298,6 +298,36 @@ def test_save_profiles(self, tmp_path: Path) -> None:
298298 assert saved_data ["current_profile" ] == "dev"
299299 assert "dev" in saved_data ["profiles" ]
300300
301+ def test_save_profiles_overwrites_existing (self , tmp_path : Path ) -> None :
302+ """Test saving profiles overwrites existing file (Windows compatibility)."""
303+ with patch ("pathlib.Path.home" , return_value = tmp_path ):
304+ manager = ProfileManager ()
305+
306+ # First save
307+ profile1 = ProfileData (
308+ region = "us" , region_url = "https://www.workato.com" , workspace_id = 123
309+ )
310+ config1 = ProfilesConfig (current_profile = "dev" , profiles = {"dev" : profile1 })
311+ manager .save_profiles (config1 )
312+
313+ # Second save should overwrite without error
314+ profile2 = ProfileData (
315+ region = "eu" , region_url = "https://app.eu.workato.com" , workspace_id = 456
316+ )
317+ config2 = ProfilesConfig (
318+ current_profile = "prod" , profiles = {"dev" : profile1 , "prod" : profile2 }
319+ )
320+ manager .save_profiles (config2 )
321+
322+ # Verify the second save succeeded
323+ profiles_file = tmp_path / ".workato" / "profiles"
324+ with open (profiles_file ) as f :
325+ saved_data = json .load (f )
326+
327+ assert saved_data ["current_profile" ] == "prod"
328+ assert "dev" in saved_data ["profiles" ]
329+ assert "prod" in saved_data ["profiles" ]
330+
301331 def test_get_profile_success (self , tmp_path : Path ) -> None :
302332 """Test getting profile data."""
303333 profile = ProfileData (
0 commit comments