Files
akyldash/infra/deploy/test_rollback.py
T
agent 6f809d3196
CI / tests-and-images (pull_request) Has been cancelled
Add guarded rollback and recovery apply tools
2026-10-11 19:30:22 +03:00

37 lines
1.4 KiB
Python

import unittest
from rollback import image_restore_plan
class RollbackPlanTests(unittest.TestCase):
def setUp(self):
self.manifest = {
"images": {
"backend": {"configured": "akyldash/backend:local", "image_id": "sha256:" + "a" * 64},
"opensearch": {"configured": "akyldash/opensearch:local", "image_id": "sha256:" + "b" * 64},
}
}
self.configured = {
"backend": "akyldash/backend:local",
"opensearch": "akyldash/opensearch:local",
}
def test_plans_only_recorded_local_images(self):
plan = image_restore_plan(self.manifest, self.configured)
self.assertEqual(plan["backend"][1], "akyldash/backend:local")
self.assertEqual(plan["opensearch"][1], "akyldash/opensearch:local")
def test_refuses_changed_compose_image_reference(self):
with self.assertRaisesRegex(ValueError, "reference changed"):
image_restore_plan(self.manifest, {**self.configured, "backend": "other/backend:tag"})
def test_refuses_digest_reference_that_cannot_be_retagged(self):
self.manifest["images"]["backend"]["configured"] = "registry/backend@sha256:" + "c" * 64
self.configured["backend"] = self.manifest["images"]["backend"]["configured"]
with self.assertRaisesRegex(ValueError, "local tag"):
image_restore_plan(self.manifest, self.configured)
if __name__ == "__main__":
unittest.main()