diff --git a/src/specify_cli/presets/catalog/command_remove.py b/src/specify_cli/presets/catalog/command_remove.py index f34ec4df99..670aa56ce3 100644 --- a/src/specify_cli/presets/catalog/command_remove.py +++ b/src/specify_cli/presets/catalog/command_remove.py @@ -72,5 +72,6 @@ def preset_catalog_remove( console.print(f"[green]✓[/green] Removed catalog '{safe_name}'") if not catalogs: console.print( - "\n[dim]No catalogs remain in config. Built-in defaults will be used.[/dim]" + "\n[dim]No project catalogs remain. The CLI will check the environment " + "override, user configuration, then built-in defaults.[/dim]" ) diff --git a/tests/specify_cli/presets/catalog/test_command_remove.py b/tests/specify_cli/presets/catalog/test_command_remove.py index 7ca289c724..e5c33120bd 100644 --- a/tests/specify_cli/presets/catalog/test_command_remove.py +++ b/tests/specify_cli/presets/catalog/test_command_remove.py @@ -9,6 +9,49 @@ class TestPresetCatalogRemove: """Test multi-catalog support in PresetCatalog.""" + def test_catalog_remove_last_entry_reports_fallback_precedence( + self, project_dir, tmp_path, monkeypatch + ): + from unittest.mock import patch + + from typer.testing import CliRunner + + from specify_cli import app + + monkeypatch.delenv("SPECKIT_PRESET_CATALOG_URL", raising=False) + home = tmp_path / "home" + monkeypatch.setattr(Path, "home", lambda: home) + user_config = home / ".specify" / "preset-catalogs.yml" + user_config.parent.mkdir(parents=True) + user_config.write_text( + "catalogs:\n- name: team-fallback\n url: https://example.com/team.json\n", + encoding="utf-8", + ) + + runner = CliRunner() + with patch.object(Path, "cwd", return_value=project_dir): + add = runner.invoke( + app, + [ + "preset", + "catalog", + "add", + "https://example.com/only.json", + "--name", + "only", + ], + ) + assert add.exit_code == 0, add.output + remove = runner.invoke(app, ["preset", "catalog", "remove", "only"]) + listing = runner.invoke(app, ["preset", "catalog", "list"]) + + assert remove.exit_code == 0, remove.output + assert listing.exit_code == 0, listing.output + assert "team-fallback" in listing.output + assert "environment override, user configuration, then built-in defaults" in ( + " ".join(remove.output.split()) + ) + @pytest.mark.parametrize( "invalid_entry", [