Test held() and the breaches a commit in the config's folder reports

This commit is contained in:
2026-11-13 02:03:07 +01:00
parent 583da20cbd
commit c180bda54b
2 changed files with 27 additions and 1 deletions
+16 -1
View File
@@ -10,7 +10,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from failure import Failure
from test_env import isolated_env
from project_config.settings import load, ProjectConfig
from project_config.settings import held, load, ProjectConfig
TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-config"
@@ -171,6 +171,21 @@ class LoadTest(ConfigCase):
self.assertIsInstance(load(self.checkout, self.checkout, self.home), ProjectConfig)
class HeldTest(ConfigCase):
def test_a_configs_folder_holds_its_config_as_the_main_checkout_reads_it(self) -> None:
folder = self.write("acme", CLIENT)
found = held(folder, self.home)
assert isinstance(found, ProjectConfig), found
self.assertEqual((found.folder, found.top, found.paths["plan"]), (folder, self.checkout, folder / "todo.md"), "the config's ~/ checkout read under home")
def test_only_a_folder_under_the_projects_folder_that_holds_a_config_is_one(self) -> None:
self.assertIsNone(held(self.home / ".claude-projects" / "empty", self.home), "no config.toml")
elsewhere = self.home / "code" / "acme"
elsewhere.mkdir()
(elsewhere / "config.toml").write_text(CLIENT, encoding="utf-8")
self.assertIsNone(held(elsewhere, self.home), "a config.toml outside ~/.claude-projects/")
class ToolTest(ConfigCase):
def run_tool(self, *args: str, cwd: pathlib.Path | None = None) -> subprocess.CompletedProcess[str]:
return subprocess.run([sys.executable, str(TOOL), *args], cwd=cwd or self.checkout, env={**isolated_env(), "HOME": str(self.home)}, capture_output=True, text=True)