mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
test(domains): read the primary domain from default.env in every test
The hardcoded-primary-domain lint exempted tests/ and scripts/tests/, so test fixtures kept their own copy of the domain and would drift from INFINITO_DOMAIN the moment it changes. The lint now scans both trees, and a unit test pins its scope: only default.env, Markdown, inventories/, .claude/ and build/ may name the domain. Python tests take the value from default_domain_primary(), and the workspace helper builds its dashboard and Matomo URLs from INFINITO_DOMAIN once the repo .env is loaded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e8cb94e246
commit
e2beab9f1c
34 files changed
+371
-290
No files matched your search
@@ -1,20 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from cli.administration.deploy.development.coredns import CoreDNSCorefileRenderer
|
||||
from utils.cache.files import PROJECT_ROOT, read_text
|
||||
from utils.domains.default_primary import default_domain_primary
|
||||
|
||||
TEMPLATE = "compose/coredns/Corefile.tmpl"
|
||||
DOMAIN = default_domain_primary()
|
||||
|
||||
|
||||
def _render() -> str:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
(root / ".env").write_text(
|
||||
'INFINITO_DOMAIN=infinito.test\nINFINITO_IP4="172.30.0.10"\n',
|
||||
f'INFINITO_DOMAIN={DOMAIN}\nINFINITO_IP4="172.30.0.10"\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
template = root / TEMPLATE
|
||||
@@ -27,16 +30,16 @@ def _render() -> str:
|
||||
class TestCoreDNSCorefileRenderer(unittest.TestCase):
|
||||
def test_the_domain_regex_is_derived_from_the_domain_escaped_once(self) -> None:
|
||||
corefile = _render()
|
||||
self.assertIn("match ^infinito\\.test\\.$", corefile)
|
||||
self.assertIn("match ^(.*)\\.infinito\\.test\\.$", corefile)
|
||||
self.assertIn(f"match ^{re.escape(DOMAIN)}\\.$", corefile)
|
||||
self.assertIn(f"match ^(.*)\\.{re.escape(DOMAIN)}\\.$", corefile)
|
||||
self.assertNotIn("\\\\", corefile)
|
||||
self.assertNotIn("${", corefile)
|
||||
|
||||
def test_the_deployment_zone_answers_every_type_itself(self) -> None:
|
||||
corefile = _render()
|
||||
catch_all = "template IN ANY infinito.test {"
|
||||
catch_all = f"template IN ANY {DOMAIN} {{"
|
||||
self.assertIn(catch_all, corefile)
|
||||
self.assertIn("IN SOA ns.infinito.test. hostmaster.infinito.test.", corefile)
|
||||
self.assertIn(f"IN SOA ns.{DOMAIN}. hostmaster.{DOMAIN}.", corefile)
|
||||
lines = corefile.splitlines()
|
||||
self.assertLess(
|
||||
max(
|
||||
|
||||
Reference in new issue
Block a user