From eda8237c36688ab1135fd959743b38be4b5a195c Mon Sep 17 00:00:00 2001 From: huanghaosheng <386998068@qq.com> Date: Sun, 1 Nov 2026 15:40:02 +0800 Subject: [PATCH] =?UTF-8?q?docs(p0-5):=20=E9=9B=86=E6=88=90=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=91=BD=E4=BB=A4=E8=A1=A5=E4=B8=8A=20-p=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 三个包的 MySQL fixture 都对同一个 schema 做 DROP 加 AutoMigrate。 包级并行会互相踩踏:`Error 1050 Table already exists` 与 `Error 1146 doesn't exist`。 因此 §9.2 的命令必须带 `-p 1`,原样执行会失败。 `AGENTS.md` 的 Integration tests 段同步写明这条约束。 验证:`go test -tags integration -p 1 -count=1 ./internal/video/ ./internal/feed/ ./internal/worker/` 全绿。 --- AGENTS.md | 2 ++ docs/solutions/P0-5-popularity-single-source.md | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 6fb0d29..520aad3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -234,6 +234,8 @@ go test -tags integration -count=1 -timeout 300s -v ./internal/middleware/rabbit Configure endpoints through env vars (`RABBITMQ_TEST_URL`, …), never hardcoded hosts. When a prerequisite is missing — a restart command, a delete-queue command — `t.Skip` with the reason; a silent pass is not a substitute for a skip. +The MySQL fixtures each `DropTable` + `AutoMigrate` the shared schema, so run more than one such package at a time with `-p 1`. Without it the packages run in parallel and drop each other's tables (`Error 1050 Table already exists`, `Error 1146 doesn't exist`). + ### Determinism and speed - No real network in unit tests; no `time.Sleep` as synchronization. Prefer channels, context deadlines, or an injected clock. Tests must pass under `-race` and in any order. diff --git a/docs/solutions/P0-5-popularity-single-source.md b/docs/solutions/P0-5-popularity-single-source.md index d58643e..34f8768 100644 --- a/docs/solutions/P0-5-popularity-single-source.md +++ b/docs/solutions/P0-5-popularity-single-source.md @@ -1704,7 +1704,9 @@ go test -race -count=1 ./... # 需要 MySQL 的部分(compose 起 mysql 后) docker compose -f ../docker-compose.yml up -d mysql -go test -tags integration -count=1 -timeout 300s ./internal/video/ ./internal/feed/ ./internal/worker/ +# -p 1 不能省:三个包的 fixture 都对同一个 schema 做 DROP + AutoMigrate, +# 包级并行会互相踩踏(Error 1050 Table already exists / Error 1146 doesn't exist)。 +go test -tags integration -p 1 -count=1 -timeout 300s ./internal/video/ ./internal/feed/ ./internal/worker/ # 前端不受影响,但类型定义有可选字段变更,仍跑一次构建 cd ../frontend && npm run build