Commit Graph

4 Commits

Author SHA1 Message Date
guke c6309f0f74 test(dev): conftest 切 shaguabijia_test(Docker PG)
conftest 在 import app 前设 test DATABASE_URL、调 ensure()+ensure_test_db()
引导 PG,fixture 改 drop_all→create_all(防持久卷残留)。ensure_pg 把
_ensure_test_db 提为公开 ensure_test_db(短路路径不建库,测试侧需显式补)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 18:46:07 +08:00
guke 5e706fd003 refactor(dev): ensure_pg 应用代码评审改进
- 所有 docker 探测/exec 加 per-call timeout(防守护进程半死时无限挂起、绕过总超时)
- _ensure_test_db 改为返回 bool 并由 ensure() 传播;建库失败(含超时)显式告警,
  与并发创建者竞争失败但库已存在(42P04)仍算就绪
- 抽出 _test_db_exists 复用;去掉一处冗余 f-string

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 18:31:02 +08:00
guke 9c55344e85 fix(dev): ensure_pg 日志对 GBK 控制台编码安全( emoji 不再崩 run.bat)
Windows cmd.exe 默认 GBK,print (U+2705)抛 UnicodeEncodeError → 脚本退非0、
run.bat 误判 ensure_pg 失败。改为启动时对 stdout/stderr 设 errors=backslashreplace:
中文照常,仅不可编码字符转义。顺带订正计划里的测试计数(11)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 18:16:11 +08:00
guke 4d3b73ae70 feat(dev): scripts/ensure_pg.py 探测/拉起本地 Docker PostgreSQL 2026-07-08 18:09:50 +08:00