Openclaw-go go-test

Run go test with race detector, analyze failures, fix issues, and re-run until green

install
source · Clone the upstream repo
git clone https://github.com/a3tai/openclaw-go
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/a3tai/openclaw-go "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.opencode/skills/go-test" ~/.claude/skills/a3tai-openclaw-go-go-test && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/a3tai/openclaw-go "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/.opencode/skills/go-test" ~/.openclaw/skills/a3tai-openclaw-go-go-test && rm -rf "$T"
manifest: .opencode/skills/go-test/SKILL.md
source content

What I do

Run the Go test suite with the race detector, analyze any failures, apply fixes, and iterate until all tests pass.

When to use me

Use this skill before committing changes, before opening a PR, or when asked to fix failing tests.

Workflow

  1. Run the full test suite:

    go test ./... -race -v
    
  2. Analyze failures — for each failing test:

    • Identify the test function and file (e.g.,
      gateway/methods_test.go:TestChatSend
      )
    • Read the test code and the code under test
    • Determine root cause: type mismatch, missing mock, logic error, race condition, etc.
  3. Fix the issue — apply the minimal correct fix:

    • If the test expectation is wrong (API changed), update the test
    • If the implementation is wrong, fix the implementation
    • If a new type/method is missing, add it
    • Never delete or skip tests to make the suite pass
  4. Re-run tests:

    go test ./... -race
    
  5. Repeat steps 2-4 until all tests pass.

  6. Run vet as a final check:

    go vet ./...
    

Test patterns in this repo

  • Table-driven tests — most tests use
    []struct{ name string; ... }
    with
    t.Run()
  • Mock gateway
    gateway/methods_test.go
    uses a mock WebSocket server that validates request frames and sends response frames
  • Race detector — always use
    -race
    ; the gateway client is concurrent and race bugs are real
  • Coverage target — aim for 100% statement coverage on library packages

Key test files

FileWhat it covers
gateway/methods_test.go
All 96+ typed RPC methods
gateway/client_test.go
Connection lifecycle, handshake, reconnect
protocol/types_test.go
Serialization round-trips
protocol/parse_test.go
Frame parsing edge cases
chatcompletions/client_test.go
HTTP client, SSE streaming
openresponses/client_test.go
Responses API, SSE events
toolsinvoke/client_test.go
Tools invoke HTTP client
discovery/browser_test.go
mDNS discovery
acp/server_test.go
JSON-RPC dispatch, handler interface

Rules

  • Never use
    -count=0
    or
    t.Skip()
    to hide failures
  • Always include
    -race
    flag
  • Fix the root cause, not the symptom
  • If a test is flaky, fix the flakiness rather than retrying