Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/specify_cli/presets/catalog/command_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
)
43 changes: 43 additions & 0 deletions tests/specify_cli/presets/catalog/test_command_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
[
Expand Down
Loading