mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 12:47:04 +00:00
guide_select built its random pool from invokable + lifecycle only, so the Guide job could pick roles whose meta/tests.yml declares every deploy mode untestable (svc-storage-nfs-client, which hard-asserts a reachable NFS server). Filter the pool by the role's declared skip for its guide mode; a malformed tests.yml now fails selection loudly instead of being silently ignored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import textwrap
|
|
import unittest
|
|
from pathlib import Path
|
|
from tempfile import TemporaryDirectory
|
|
|
|
from cli.meta.ci import guide_select
|
|
from utils.cache.files import PROJECT_ROOT
|
|
from utils.roles.mapping import ROLE_FILE_META_TESTS
|
|
from utils.roles.meta_lookup import MetaServicesShapeError, get_role_test_skips
|
|
|
|
|
|
class GuideModeTests(unittest.TestCase):
|
|
def test_role_without_stack_deploys_in_host_mode(self):
|
|
self.assertEqual(
|
|
guide_select._guide_mode(PROJECT_ROOT / "roles" / "svc-storage-nfs-client"),
|
|
"host",
|
|
)
|
|
|
|
def test_role_with_stack_deploys_in_compose_mode(self):
|
|
self.assertEqual(
|
|
guide_select._guide_mode(PROJECT_ROOT / "roles" / "web-app-yourls"),
|
|
"compose",
|
|
)
|
|
|
|
|
|
class TestableRolesTests(unittest.TestCase):
|
|
def test_pool_excludes_roles_whose_guide_mode_is_skipped(self):
|
|
pool = guide_select._testable_roles()
|
|
self.assertNotIn("svc-storage-nfs-client", pool)
|
|
self.assertTrue(pool)
|
|
|
|
def test_malformed_tests_yml_fails_selection_loudly(self):
|
|
with TemporaryDirectory() as tmp:
|
|
role_dir = Path(tmp) / "web-app-broken"
|
|
tests_path = role_dir / ROLE_FILE_META_TESTS
|
|
tests_path.parent.mkdir(parents=True)
|
|
tests_path.write_text(
|
|
textwrap.dedent(
|
|
"""
|
|
---
|
|
skip: not-a-list
|
|
"""
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
with self.assertRaises(MetaServicesShapeError):
|
|
get_role_test_skips(role_dir, role_name=role_dir.name)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|