Answer stability round 1: 1 🔴, 4 🟡 (1 misread); refuse an env-file in the main checkout from a worktree, test the DM wiring in-process, and record why an unreadable config skips the DM
This commit is contained in:
@@ -179,6 +179,16 @@ class LoadTest(ConfigCase):
|
||||
self.assertIn("`env-file`", reason)
|
||||
self.assertNotIn("is not a setting", reason)
|
||||
|
||||
def test_a_worktree_refuses_an_env_file_in_the_main_checkout_as_well_as_one_in_its_own_files(self) -> None:
|
||||
for case, folder in {"the main checkout": "acme-billing", "the worktree": "acme-billing-item-3"}.items():
|
||||
with self.subTest(case=case), tempfile.TemporaryDirectory() as made:
|
||||
self.home = pathlib.Path(made).resolve()
|
||||
self.checkout = self.home / "code" / "acme-billing"
|
||||
self.write("acme", CLIENT + f'env-file = "{self.home}/code/{folder}/.env"\n')
|
||||
found = load(self.home / "code" / "acme-billing-item-3", self.checkout, self.home)
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertIn("`env-file`", found.reason)
|
||||
|
||||
def test_the_failure_for_a_misplaced_env_file_and_a_missing_setting_names_both_and_lists_every_setting(self) -> None:
|
||||
folder = self.write("acme", "".join(line + "\n" for line in CLIENT.splitlines() if not line.startswith("plan")) + 'env-file = "checkout:.env"\n')
|
||||
self.assertEqual(self.failure(), f"{folder / 'config.toml'}: `plan` is missing; `env-file` is 'checkout:.env', not {OUTSIDE}. The settings are {', '.join(SETTINGS)}, and optionally env-file.")
|
||||
@@ -246,6 +256,16 @@ class ToolTest(ConfigCase):
|
||||
one = self.run_tool("changelog", cwd=self.checkout / "src")
|
||||
self.assertEqual((one.returncode, one.stdout), (0, f"{self.checkout}/CHANGELOG.md\n"))
|
||||
|
||||
def test_prints_the_env_file_where_the_config_sets_one_and_fails_asking_for_it_where_it_does_not(self) -> None:
|
||||
folder = self.write("acme", CLIENT)
|
||||
unset = self.run_tool("env-file")
|
||||
self.assertEqual((unset.returncode, unset.stdout, unset.stderr), (1, "", f"{folder / 'config.toml'} sets no `env-file`\n"))
|
||||
self.assertNotIn("env-file", self.run_tool().stdout)
|
||||
(folder / "config.toml").write_text(CLIENT + 'env-file = "~/.claude-projects/acme.env"\n')
|
||||
one = self.run_tool("env-file")
|
||||
self.assertEqual((one.returncode, one.stdout), (0, f"{self.home}/.claude-projects/acme.env\n"))
|
||||
self.assertEqual(self.run_tool().stdout.splitlines()[-1], f"env-file: {self.home}/.claude-projects/acme.env")
|
||||
|
||||
def test_fails_on_stderr(self) -> None:
|
||||
cases = {"no config": ((), "no config names the checkout"), "an unknown setting": (("readme",), "usage:"), "two arguments": (("plan", "changelog"), "usage:")}
|
||||
for case, (args, said) in cases.items():
|
||||
|
||||
Reference in New Issue
Block a user