mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
3529 invalid comments in 528 files, grandfathered in while the linter only saw the working-tree diff. Removal ran through the linter's own collectors, so detection and deletion cannot drift: a comment whose opener line is blank before it and whose closer line is blank after it loses all its lines, anything else loses only the comment region, and a line left holding a bare delimiter goes with it. Five files keep their comments behind a nocheck marker instead. Four are upstream configs whose inline docs are upstream's own (mautrix, systemd journald, nextcloud-oidc-login, MediaWiki). In littlejs the commented-out entries ARE the deactivation mechanism for an example tile, so deleting them would delete configuration. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
import unittest
|
|
from collections import defaultdict
|
|
|
|
from utils.cache.applications import get_application_defaults
|
|
|
|
from . import PROJECT_ROOT
|
|
|
|
|
|
class TestDomainUniqueness(unittest.TestCase):
|
|
def test_no_duplicate_domains(self):
|
|
"""
|
|
Build application defaults directly from roles,
|
|
collect all entries under domains.canonical and domains.aliases across all applications,
|
|
and assert that no domain appears more than once.
|
|
"""
|
|
repo_root = PROJECT_ROOT
|
|
apps = get_application_defaults(roles_dir=repo_root / "roles")
|
|
|
|
domain_to_apps = defaultdict(set)
|
|
|
|
for app_name, app_cfg in apps.items():
|
|
domains_cfg = app_cfg.get("server", {}).get("domains", {})
|
|
|
|
canonical = domains_cfg.get("canonical", [])
|
|
if isinstance(canonical, dict):
|
|
values = list(canonical.values())
|
|
else:
|
|
values = canonical or []
|
|
|
|
for d in values:
|
|
if isinstance(d, str) and d.strip():
|
|
domain_to_apps[d].add(app_name)
|
|
|
|
aliases = domains_cfg.get("aliases", [])
|
|
if isinstance(aliases, dict):
|
|
values = list(aliases.values())
|
|
else:
|
|
values = aliases or []
|
|
|
|
for d in values:
|
|
if isinstance(d, str) and d.strip():
|
|
domain_to_apps[d].add(app_name)
|
|
|
|
duplicates = {
|
|
domain: list(apps)
|
|
for domain, apps in domain_to_apps.items()
|
|
if len(apps) > 1
|
|
}
|
|
if duplicates:
|
|
details = "\n".join(
|
|
f"Domain '{domain}' is used in applications: {apps}"
|
|
for domain, apps in duplicates.items()
|
|
)
|
|
self.fail(
|
|
f"Duplicate domain entries found:\n{details}\n(Maybe 'make build' solves this issue.)"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|