AgentSkillsCN

test

使用容器化的 Go 工具链,为本仓库(Go API/消费者)运行并排查测试。适用场景:当用户要求运行测试、验证变更、调查失败的测试,或应对 CI 失败时。涵盖单元测试,以及可选的集成并发测试。

SKILL.md
--- frontmatter
name: test
description: Run and troubleshoot tests for this repository (Go API/consumer) using the containerized Go toolchain. Use when the user asks to run tests, verify a change, investigate a failing test, or respond to CI failures. Covers unit tests and the optional integration concurrency test.

Test

Quick start

Prefer the repository’s containerized Go toolchain so local Go versions don’t matter.

Unit tests (default)

Run all unit tests:

bash
docker run --rm -v "$PWD":/src -w /src golang:1.25.6-alpine sh -c "go test ./..."

If you only changed a specific area, prefer a narrower command first (faster), e.g.:

bash
docker run --rm -v "$PWD":/src -w /src golang:1.25.6-alpine sh -c "go test ./internal/..."

Integration test (optional; requires Docker)

Run the concurrency integration test (testcontainers):

bash
RUN_INTEGRATION=1 docker run --rm -v "$PWD":/src -w /src golang:1.25.6-alpine sh -c "go test ./... -run TestConcurrentReviewCreates_UpdateAggregates"

When tests fail (workflow)

  1. Re-run the smallest reproducer:
    • If only one package fails, re-run go test for that package.
    • If a single test fails, re-run with -run <TestName>.
  2. Read the failure output and identify:
    • exact failing test name(s)
    • expected vs actual
    • whether the failure is deterministic or flaky
  3. Fix the root cause (not the symptom), then re-run:
    • the failing test(s)
    • the broader package
    • finally go test ./... (unit) and, if relevant, the integration test above

Notes specific to this repo

  • Use docker compose up -d --build to start Postgres/Redis/RabbitMQ when you need runtime dependencies, but unit tests should generally not require it.
  • Integration tests requiring Docker should be run only when relevant to the change or when explicitly requested.