fix: main project always recreated on project list command (#421) · basicmachines-co/basic-memory@cad7019 · GitHub
Skip to content

Commit cad7019

Browse files
authored
fix: main project always recreated on project list command (#421)
1 parent 099c334 commit cad7019

3 files changed

Lines changed: 74 additions & 14 deletions

File tree

src/basic_memory/config.py

Lines changed: 8 additions & 5 deletions

test-int/cli/test_project_commands_integration.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,45 @@ def test_project_set_default(app_config, config_manager):
119119
for line in lines:
120120
if "another-project" in line:
121121
assert "[X]" in line
122+
123+
124+
def test_remove_main_project(app_config, config_manager):
125+
"""Test that removing main project then listing projects prevents main from reappearing (issue #397)."""
126+
runner = CliRunner()
127+
128+
# Create separate temp dirs for each project
129+
with (
130+
tempfile.TemporaryDirectory() as main_dir,
131+
tempfile.TemporaryDirectory() as new_default_dir,
132+
):
133+
main_path = Path(main_dir)
134+
new_default_path = Path(new_default_dir)
135+
136+
# Ensure main exists
137+
result = runner.invoke(app, ["project", "list"])
138+
if "main" not in result.stdout:
139+
result = runner.invoke(app, ["project", "add", "main", str(main_path)])
140+
print(result.stdout)
141+
assert result.exit_code == 0
142+
143+
# Confirm main is present
144+
result = runner.invoke(app, ["project", "list"])
145+
assert "main" in result.stdout
146+
147+
# Add a second project
148+
result = runner.invoke(app, ["project", "add", "new_default", str(new_default_path)])
149+
assert result.exit_code == 0
150+
151+
# Set new_default as default (if needed)
152+
result = runner.invoke(app, ["project", "default", "new_default"])
153+
assert result.exit_code == 0
154+
155+
# Remove main
156+
result = runner.invoke(app, ["project", "remove", "main"])
157+
assert result.exit_code == 0
158+
159+
# Confirm only new_default exists and main does not
160+
result = runner.invoke(app, ["project", "list"])
161+
assert result.exit_code == 0
162+
assert "main" not in result.stdout
163+
assert "new_default" in result.stdout

tests/test_config.py

Lines changed: 24 additions & 9 deletions

0 commit comments

Comments
 (0)