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