test(release): qualify SQLite archive producers on Windows

This commit is contained in:
cesnimda
2026-11-19 14:09:20 +01:00
parent 5718d9521b
commit 67b9b67519
2 changed files with 44 additions and 0 deletions
+31
View File
@@ -423,6 +423,37 @@ class BackupSqlTrailerTests(unittest.TestCase):
class BackupDatabaseMemberTests(unittest.TestCase):
def test_host_tar_producer_with_database_and_sidecar(self):
producer = shutil.which('tar')
self.assertIsNotNone(producer, 'The host tar command is required for producer qualification.')
with tempfile.TemporaryDirectory() as temporary:
folder = Path(temporary)
volume = folder / 'data'
volume.mkdir()
database = volume / 'jobtracker.db'
connection = sqlite3.connect(database)
try:
with connection:
connection.execute('CREATE TABLE synthetic (id INTEGER PRIMARY KEY)')
connection.execute('INSERT INTO synthetic VALUES (1)')
finally:
connection.close()
(volume / 'jobtracker.db-wal').write_bytes(b'fixture sidecar name only')
for case in ('database-and-sidecar', 'sidecar-only'):
with self.subTest(case=case):
if case == 'sidecar-only':
database.unlink()
archive = case + '.tar.gz'
subprocess.run([producer, 'czf', archive, '-C', 'data', '.'],
cwd=folder, check=True, capture_output=True, timeout=15)
result = subprocess.run([sys.executable, ROOT / 'scripts/validate-sqlite-backup.py', archive],
cwd=folder, capture_output=True, timeout=15)
self.assertEqual(0 if database.exists() else 1, result.returncode, result.stderr)
if database.exists():
with tarfile.open(folder / archive, 'r:gz') as bundle:
with bundle.extractfile('./jobtracker.db') as archived:
self.assertEqual(database.read_bytes(), archived.read())
def verify_archive(self, member_name, truncated_tar=False, member_type=tarfile.REGTYPE, contents=None):
source = (ROOT / 'deploy/deploy.sh').read_text(encoding='utf-8')
functions = []