Dumps stream through gzip into <db>.backup.sql.gz; no uncompressed copy touches the disk. Restore reads gzip and plain dumps by their magic bytes, verifies a gzip dump to its end before anything is dropped, and still finds the uncompressed names of older generations. The manifest names the compression. 🎯 Fix: 92 % 💥 Break: 20 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: ~100 % 🏆 Score: 74 🚦 Gate: ⛔ break 20 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.8 KiB
Python
58 lines
1.8 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,
|
|
patch.object(cli, "locate", side_effect=lambda path: path),
|
|
):
|
|
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()
|