import pathlib import re import unittest ROOT = pathlib.Path(__file__).resolve().parents[1] class NtfyManifestTest(unittest.TestCase): def test_kustomization_includes_internal_ntfy_utility_resources(self): source = (ROOT / 'deploy/k8s/base/kustomization.yaml').read_text() self.assertIn('utility-namespace.yaml', source) self.assertIn('ntfy.yaml', source) def test_ntfy_manifest_is_internal_clusterip_service_with_health_checks(self): source = (ROOT / 'deploy/k8s/base/ntfy.yaml').read_text() self.assertIn('namespace: utility', source) self.assertIn('image: binwiederhier/ntfy:v2.21.0', source) self.assertRegex(source, r'kind: Service[\s\S]*type: ClusterIP') self.assertIn('path: /v1/health', source) self.assertIn('base-url: http://ntfy.utility.svc.cluster.local', source) self.assertNotIn('kind: Ingress', source) def test_unrip_services_receive_internal_notification_endpoint(self): source = (ROOT / 'deploy/k8s/base/unrip.yaml').read_text() self.assertIn('NOTIFICATION_NTFY_BASE_URL: http://ntfy.utility.svc.cluster.local', source) self.assertIn('NOTIFICATION_NTFY_TOPIC: unrip', source) def test_workflow_waits_for_ntfy_rollout_without_rewriting_external_image(self): source = (ROOT / '.forgejo/workflows/deploy.yml').read_text() self.assertIn('kubectl -n utility rollout status deployment/ntfy --timeout=180s', source) self.assertNotRegex(source, re.compile(r'set image "deployment/ntfy"')) if __name__ == '__main__': unittest.main()