test(backups): test that we do return snapshot on backup

This commit is contained in:
Houkime 2023-04-03 17:23:16 +00:00 committed by Inex Code
parent 35a4fec9d4
commit d57dc3f7d2
2 changed files with 12 additions and 0 deletions

View file

@ -87,6 +87,7 @@ class ResticBackuper(AbstractBackuper):
for message in messages: for message in messages:
if message["message_type"] == "summary": if message["message_type"] == "summary":
return ResticBackuper._snapshot_from_fresh_summary(message, repo_name) return ResticBackuper._snapshot_from_fresh_summary(message, repo_name)
raise ValueError("no summary message in restic json output")
@staticmethod @staticmethod
def _snapshot_from_fresh_summary(message: object, repo_name) -> Snapshot: def _snapshot_from_fresh_summary(message: object, repo_name) -> Snapshot:

View file

@ -130,6 +130,17 @@ def test_one_snapshot(backups, dummy_service):
assert snap.service_name == dummy_service.get_id() assert snap.service_name == dummy_service.get_id()
def test_backup_returns_snapshot(backups, dummy_service):
service_folder = dummy_service.get_location()
provider = Backups.provider()
name = dummy_service.get_id()
snapshot = provider.backuper.start_backup(service_folder, name)
assert snapshot.id is not None
assert snapshot.service_name == name
assert snapshot.created_at is not None
def test_restore(backups, dummy_service): def test_restore(backups, dummy_service):
service_folder = dummy_service.get_location() service_folder = dummy_service.get_location()
file_to_nuke = listdir(service_folder)[0] file_to_nuke = listdir(service_folder)[0]