Harden backup credentials and add durable image inventory publication
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a06ecb-456a-71c2-b41e-0755d336e883
This commit is contained in:
parent
62423fd092
commit
0349a08e1b
13 changed files with 365 additions and 23 deletions
42
tests/test_live_images_inventory.py
Normal file
42
tests/test_live_images_inventory.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import importlib.util
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
SPEC = importlib.util.spec_from_file_location(
|
||||
"refresh_live_images", Path(__file__).resolve().parents[1] / "scripts/refresh_live_images.py"
|
||||
)
|
||||
inventory = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(inventory)
|
||||
|
||||
|
||||
class InventoryTests(unittest.TestCase):
|
||||
def test_refresh_preserves_other_clusters_and_previous_tags(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
output = root / "durable" / "images.txt"
|
||||
first, second = root / "first", root / "second"
|
||||
first.write_text("forgejo.example/org/app:old\n")
|
||||
second.write_text("forgejo.example/org/other:live\n")
|
||||
inventory.refresh(output, [first, second])
|
||||
first.write_text("forgejo.example/org/app:new\n")
|
||||
receipt = inventory.refresh(output, [first])
|
||||
self.assertEqual(receipt["images"], 3)
|
||||
self.assertIn("forgejo.example/org/other:live", output.read_text())
|
||||
self.assertIn("forgejo.example/org/app:old", output.read_text())
|
||||
self.assertEqual(inventory.refresh(output, [first]), receipt)
|
||||
|
||||
def test_failed_export_preserves_inventory(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
output, source = root / "images", root / "export"
|
||||
output.write_text("forgejo.example/org/app:live\n")
|
||||
before = output.read_bytes()
|
||||
for content in ["", "# no images\n", "error fetching pods\n"]:
|
||||
source.write_text(content)
|
||||
with self.assertRaises(ValueError):
|
||||
inventory.refresh(output, [source])
|
||||
self.assertEqual(output.read_bytes(), before)
|
||||
with self.assertRaises(OSError):
|
||||
inventory.refresh(output, [root / "missing"])
|
||||
self.assertEqual(output.read_bytes(), before)
|
||||
Loading…
Add table
Add a link
Reference in a new issue