mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2026-08-20 13:12:48 +00:00
feat(backup)!: mandatory repo-name and databases-csv, --only-files, --only-sql
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>
This commit is contained in:
33
tests/e2e/test_e2e_cli_contract_only_sql.py
Normal file
33
tests/e2e/test_e2e_cli_contract_only_sql.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import unittest
|
||||
|
||||
from .helpers import run
|
||||
|
||||
WITHDRAWN_FLAGS = ["--dump-only", "--dump-only-sql", "--everything"]
|
||||
|
||||
|
||||
class TestE2ECLIContractOnlySql(unittest.TestCase):
|
||||
def test_help_mentions_the_flag(self) -> None:
|
||||
cp = run(["baudolo", "--help"], capture=True, check=True)
|
||||
out = (cp.stdout or "") + "\n" + (cp.stderr or "")
|
||||
self.assertIn(
|
||||
"--only-sql",
|
||||
out,
|
||||
f"Expected '--only-sql' to appear in --help output. Output:\n{out}",
|
||||
)
|
||||
|
||||
def test_a_withdrawn_flag_is_rejected(self) -> None:
|
||||
for flag in WITHDRAWN_FLAGS:
|
||||
with self.subTest(flag=flag):
|
||||
cp = run(["baudolo", flag], capture=True, check=False)
|
||||
self.assertEqual(
|
||||
cp.returncode,
|
||||
2,
|
||||
f"Expected exitcode 2 for unknown args, got {cp.returncode}\n"
|
||||
f"STDOUT={cp.stdout}\nSTDERR={cp.stderr}",
|
||||
)
|
||||
err = (cp.stderr or "") + "\n" + (cp.stdout or "")
|
||||
# Argparse typically prints "unrecognized arguments"
|
||||
self.assertTrue(
|
||||
("unrecognized arguments" in err) or ("usage:" in err.lower()),
|
||||
f"Expected argparse-style error output. Output:\n{err}",
|
||||
)
|
||||
Reference in New Issue
Block a user