mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-20 21:22:54 +00:00
Two defaults could not be right. --repo-name fell back to the literal 'backup-docker-to-local' while its help promised the git repo folder name, which nothing ever derived. --databases-csv pointed inside the installed package directory, where credentials must not live; when it applied, load_databases_df read a missing file as empty and the run finished without a single dump and without an error. Both are required now, --repo-name in the restore CLI too. The file itself may still be absent - babadcb's tolerance is untouched, only the path must be named. --everything is withdrawn. Its one effect was to ignore --images-no-stop-required, which is what leaving that list empty already does, and its branch was the default path minus the requires_stop check. No caller, no test, and help and README described it differently. --dump-only-sql becomes --only-sql, and --only-files joins it as the opposite half: no dumps at all, every volume as files. They form a mutually exclusive group. A host that only copies files has no business holding database passwords, so --databases-csv is not required there and is never read. The smallest valid argv turned out to be written four times across the test tree; it now lives once. Withdrawn flags are listed in one place and proven to exit 2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from baudolo.restore import __main__ as cli
|
|
|
|
ENGINES = {
|
|
"postgres": ("restore_postgres_sql", ["--db-name", "app"]),
|
|
"mariadb": ("restore_mariadb_sql", ["--db-name", "app"]),
|
|
"cluster": ("restore_cluster_sql", ["--instance", "central", "--db-user", "root"]),
|
|
}
|
|
|
|
|
|
class TestVersionFlagReachesEveryEngine(unittest.TestCase):
|
|
def call(self, engine: str, extra: list) -> dict:
|
|
target, required = ENGINES[engine]
|
|
argv = [
|
|
engine,
|
|
"app_vol",
|
|
"hash",
|
|
"20260817000000",
|
|
"--repo-name",
|
|
"repo",
|
|
"--container",
|
|
"db",
|
|
"--db-password",
|
|
"pw",
|
|
*required,
|
|
*extra,
|
|
]
|
|
with patch.object(cli, target) as restore:
|
|
self.assertEqual(cli.main(argv), 0)
|
|
return restore.call_args.kwargs
|
|
|
|
def test_the_gate_is_on_by_default(self) -> None:
|
|
for engine in ENGINES:
|
|
with self.subTest(engine=engine):
|
|
self.assertTrue(self.call(engine, [])["check_version"])
|
|
|
|
def test_the_flag_turns_it_off(self) -> None:
|
|
for engine in ENGINES:
|
|
with self.subTest(engine=engine):
|
|
kwargs = self.call(engine, ["--no-version-check"])
|
|
self.assertFalse(kwargs["check_version"])
|
|
|
|
def test_empty_stays_independent_of_the_gate(self) -> None:
|
|
for engine in ENGINES:
|
|
with self.subTest(engine=engine):
|
|
kwargs = self.call(engine, ["--empty"])
|
|
self.assertTrue(kwargs["empty"])
|
|
self.assertTrue(kwargs["check_version"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|