mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 14:13:12 +00:00
Keep application and Terraform changes in separate PRs so a merge cannot race an HCP apply against an app deploy.
59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for check_app_terraform_isolation.isolation_violation."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from check_app_terraform_isolation import isolation_violation
|
|
|
|
|
|
class IsolationTests(unittest.TestCase):
|
|
def test_terraform_only(self) -> None:
|
|
self.assertIsNone(
|
|
isolation_violation(
|
|
[
|
|
"terraform/live/dev/main.tf",
|
|
"terraform/live/README.md",
|
|
]
|
|
)
|
|
)
|
|
|
|
def test_app_only(self) -> None:
|
|
self.assertIsNone(
|
|
isolation_violation(
|
|
[
|
|
"Api.SeaHavenIndustries/Controllers/WorkOrderController.cs",
|
|
".ebextensions/01_migrations.config",
|
|
"scripts/package-elastic-beanstalk.sh",
|
|
]
|
|
)
|
|
)
|
|
|
|
def test_docs_and_workflows_with_terraform(self) -> None:
|
|
self.assertIsNone(
|
|
isolation_violation(
|
|
[
|
|
"terraform/live/modules/environment-owned/main.tf",
|
|
".github/workflows/deploy.yaml",
|
|
"QUALITY_GATES.md",
|
|
"scripts/governance-check.sh",
|
|
]
|
|
)
|
|
)
|
|
|
|
def test_mixed_app_and_terraform_fails(self) -> None:
|
|
violation = isolation_violation(
|
|
[
|
|
"terraform/live/dev/main.tf",
|
|
"SeaHaven.Services/Implementation/WorkOrderService.cs",
|
|
]
|
|
)
|
|
self.assertIsNotNone(violation)
|
|
terraform_files, app_files = violation or ([], [])
|
|
self.assertEqual(terraform_files, ["terraform/live/dev/main.tf"])
|
|
self.assertTrue(any(path.endswith(".cs") for path in app_files))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|