Pin approval-clients rollout tests to their pre-rollout fixture
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

deployment.yaml advanced past the one-shot rollout (P05/P06), so the helper
correctly refused it with prior_image_drift and existing_candidate_env. The
fixture now reconstructs the pre-rollout state, and a new test asserts the
helper refuses the current declaration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 299762@bnt-lap001
Assistant-Session: d3d3cea1-869c-44f1-be2a-3d6d3550e72e
This commit is contained in:
tegwick 2026-09-23 19:56:55 +02:00
parent 7d42c6b32c
commit 444f2b3fc3

View file

@ -23,6 +23,15 @@ def fixture(raw=None):
def deployment(): def deployment():
source = next(yaml.safe_load_all((PATH.parent / 'deployment.yaml').read_text())) source = next(yaml.safe_load_all((PATH.parent / 'deployment.yaml').read_text()))
source['metadata'].update(uid='99ddd83c-cb3f-4847-bcf8-35f1aa87627f', resourceVersion='101') source['metadata'].update(uid='99ddd83c-cb3f-4847-bcf8-35f1aa87627f', resourceVersion='101')
# The helper is a one-shot rollout from PRIOR_IMAGE; deployment.yaml has
# since advanced past it, so reduce the fixture to the pre-rollout state:
# the prior image and none of the approval-client env the helper adds.
container = next(c for c in source['spec']['template']['spec']['containers'] if c['name'] == 'keycape')
container['image'] = m.PRIOR_IMAGE
added = {x['name'] for x in yaml.safe_load(
(m.KEYCAPE / 'docs/approval-clients-deployment.patch.yaml').read_text()
)['spec']['template']['spec']['containers'][0]['env']}
container['env'] = [x for x in container.get('env', []) if x['name'] not in added]
return source return source
@ -64,6 +73,11 @@ class RolloutTests(unittest.TestCase):
self.assertEqual(after[field], before[field]) self.assertEqual(after[field], before[field])
self.assertEqual(after['image'], m.IMAGE) self.assertEqual(after['image'], m.IMAGE)
def test_candidate_refuses_current_declared_image(self):
current = next(yaml.safe_load_all((PATH.parent / 'deployment.yaml').read_text()))
with self.assertRaisesRegex(m.LaneError, 'prior_image_drift'):
m.candidate_spec(current)
def test_cas_patch_contains_both_preconditions_and_stdin_only(self): def test_cas_patch_contains_both_preconditions_and_stdin_only(self):
with patch.object(m, 'command') as command: with patch.object(m, 'command') as command:
command.return_value.stdout = b'{}' command.return_value.stdout = b'{}'