Files
taxbaik/scripts/validate_locked_db_connection.py
T
kjh2064 d2d162d58b
TaxBaik CI/CD / build-and-deploy (push) Successful in 3m33s
Make DB lock validation CI friendly
2026-07-07 16:15:46 +09:00

45 lines
1.3 KiB
Python

import json
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[1]
EXPECTED = "Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=taxbaik123"
TARGETS = [
ROOT / "src" / "TaxBaik.Web" / "appsettings.json",
ROOT / "src" / "TaxBaik.Web" / "appsettings.Development.json",
]
def main() -> int:
print(f"cwd: {Path.cwd()}")
print(f"repo_root: {ROOT}")
failed = False
for path in TARGETS:
try:
print(f"checking: {path}")
if not path.exists():
if path.name == "appsettings.Development.json":
print(f"SKIP: {path} not present in this checkout")
continue
raise FileNotFoundError(path)
data = json.loads(path.read_text(encoding="utf-8"))
actual = data["ConnectionStrings"]["Default"]
except Exception as exc:
print(f"ERROR: {path} could not be read: {exc}")
failed = True
continue
if actual != EXPECTED:
print(f"ERROR: {path} connection string mismatch")
print(f" expected: {EXPECTED}")
print(f" actual: {actual}")
failed = True
else:
print(f"OK: {path} connection string locked")
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())