diff --git a/bin/mattermost_dm/test_mattermost_dm.py b/bin/mattermost_dm/test_mattermost_dm.py index 446db2eb..afd74d4a 100644 --- a/bin/mattermost_dm/test_mattermost_dm.py +++ b/bin/mattermost_dm/test_mattermost_dm.py @@ -256,6 +256,10 @@ class Dm(Project): assert isinstance(failed, Failure), failed self.assertEqual(failed.reason, f"{self.folder / 'config.toml'} sets no `env-file`; it needs the file that holds MATTERMOST_URL, MATTERMOST_TOKEN and MATTERMOST_RECIPIENT") + def test_config_of_reads_the_env_file_the_config_names(self): + self.name_env_file("MATTERMOST_URL=https://chat.example/\nMATTERMOST_TOKEN=secret-token\nMATTERMOST_RECIPIENT=lilleman\n") + self.assertEqual(dm.config_of(str(self.checkout), self.home), CONFIG) + def test_no_failure_it_gives_holds_the_token_however_the_request_fails(self): self.name_env_file("MATTERMOST_URL=https://127.0.0.1:1\nMATTERMOST_TOKEN=secret-token\nMATTERMOST_RECIPIENT=lilleman\n") failed = dm.dm("Which one?", str(self.checkout), self.home, dm.http_json) diff --git a/bin/project_config/test_project_config.py b/bin/project_config/test_project_config.py index 051fcab1..36b9b99b 100644 --- a/bin/project_config/test_project_config.py +++ b/bin/project_config/test_project_config.py @@ -9,7 +9,7 @@ import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure -from project_config.settings import held, load, ProjectConfig, SETTINGS +from project_config.settings import held, load, OUTSIDE, ProjectConfig, SETTINGS from test_env import isolated_env TOOL = pathlib.Path(__file__).resolve().parents[1] / "project-config" @@ -179,6 +179,10 @@ class LoadTest(ConfigCase): self.assertIn("`env-file`", reason) self.assertNotIn("is not a setting", 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.") + def test_two_configs_naming_one_checkout_fail_naming_both(self) -> None: self.write("acme", CLIENT) self.write("acme-copy", CLIENT)