fix that alias can only exist once and when dublicate give error
This commit is contained in:
@@ -45,6 +45,27 @@ def test_clients_rename_uses_global_browser_target_when_set():
|
||||
send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile=None)
|
||||
assert "Restart the browser" not in result.output
|
||||
|
||||
def test_clients_rename_rejects_duplicate_alias(tmp_path):
|
||||
registry_path = tmp_path / "registry.json"
|
||||
registry_path.write_text('{"work": "/tmp/work.sock", "old-id": "/tmp/old-id.sock"}', encoding="utf-8")
|
||||
|
||||
with patch("browser_cli.cli.REGISTRY_PATH", registry_path), patch("browser_cli.cli.send_command") as send_command:
|
||||
result = CliRunner().invoke(main, ["clients", "rename", "--browser", "old-id", "work"])
|
||||
|
||||
assert result.exit_code != 0
|
||||
assert "Browser alias 'work' already exists" in result.output
|
||||
send_command.assert_not_called()
|
||||
|
||||
def test_clients_rename_allows_same_alias_for_same_target(tmp_path):
|
||||
registry_path = tmp_path / "registry.json"
|
||||
registry_path.write_text('{"work": "/tmp/work.sock"}', encoding="utf-8")
|
||||
|
||||
with patch("browser_cli.cli.REGISTRY_PATH", registry_path), patch("browser_cli.cli.send_command") as send_command:
|
||||
result = CliRunner().invoke(main, ["clients", "rename", "--browser", "work", "work"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
send_command.assert_called_once_with("clients.rename_profile", {"alias": "work"}, profile="work")
|
||||
|
||||
def test_install_help_lists_supported_browsers():
|
||||
result = CliRunner().invoke(main, ["install", "--help"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user