Pause backup scheduling and atomically deploy workstation updates

This commit is contained in:
admin committed 2026-10-26 12:38:11 +01:00
1 parent 8245571f15
commit a1a843a6f7
4 files changed
+39 -6

No files matched your search

+24
View File
@@ -175,6 +175,30 @@ class BackupTests(unittest.TestCase):
with self.assertRaises(m.BackupError):
self.runner.validate_final_inventory(before, after)
def test_installer_preserves_config_and_key_and_pauses_timer(self):
home = self.root/'install-home'
config = home/'.config/nextcloud-borg-backup'
config.mkdir(parents=True)
(config/'config').write_text('# preserved custom config\n')
(config/'passphrase').write_text('existing-test-key')
fake = self.root/'fake-bin'
fake.mkdir()
commands = self.root/'systemctl-calls'
(fake/'systemctl').write_text('#!/bin/sh\nprintf "%s\\n" "$*" >> "$CALL_LOG"\nexit 0\n')
(fake/'systemctl').chmod(0o755)
env = dict(os.environ, HOME=str(home), XDG_CONFIG_HOME=str(home/'.config'),
XDG_STATE_HOME=str(home/'.local/state'), PATH=str(fake)+':'+os.environ['PATH'],
CALL_LOG=str(commands))
subprocess.run([str(ROOT/'scripts/install.sh')], env=env, check=True, stdout=subprocess.DEVNULL)
self.assertEqual((config/'config').read_text(), '# preserved custom config\n')
self.assertEqual((config/'passphrase').read_text(), 'existing-test-key')
calls = commands.read_text()
self.assertIn('stop nextcloud-borg-backup.service nextcloud-borg-backup.timer', calls)
self.assertIn('restart nextcloud-borg-backup.timer nextcloud-borg-health.timer', calls)
self.assertEqual((home/'.local/libexec/nextcloud-borg-runner.py').read_bytes(),
(ROOT/'scripts/nextcloud-borg-runner.py').read_bytes())
self.assertEqual(list(home.rglob('*.new')), [])
def test_pending_maintenance_survives_interrupted_attempt_record(self):
import time
self.runner.success = {'completed_at': time.time(), 'maintenance_pending': True}