Files
AirCoding/packages/opencode/test/server/AGENTS.md
airlongdian e2fd375a1c feat: 品牌替换 + 启动优化 + AGENTS.md 模板定制
- 品牌替换:OpenCode/opencode → AirCoding/aircoding(16+ 文件)
- Logo ASCII art:修复 left/right 行数不匹配导致的启动崩溃
- 启动诊断:添加 OPENCODE_PRINT_TIMING 计时探针
- dev 模式默认 --pure 跳过外部插件加载
- AGENTS.md 模板:追加 AirCoding 多 Agent 专项段落
- architect prompt + plugin:强化 AGENTS.md 产出验证
2026-06-14 09:31:29 +08:00

1.7 KiB

Server Test Guide

Use these patterns for server and HttpApi middleware tests in this directory.

  • Prefer focused middleware tests with tiny fake routes over full API route trees when testing routing, context, proxying, or middleware policy.
  • Use testEffect(...) with NodeHttpServer.layerTest for the primary in-test server and make relative HttpClient requests against it.
  • Use tiny HttpApiBuilder probe groups that declare the typed middleware under test and expose context such as WorkspaceRouteContext, InstanceRef, or WorkspaceRef.
  • Declare middleware in the same order as production when testing interactions, for example InstanceContextMiddleware followed by WorkspaceRoutingMiddleware.
  • For secondary upstream servers, build Effect NodeHttpServer.layer(...) into the current test scope with Layer.build(...) so the listener stays alive until the test scope exits.
  • Avoid Bun.serve when testing Effect HTTP middleware. Keep the test in the Effect HTTP stack unless the production path being tested is Bun-specific.
  • For WebSocket paths, use Socket.makeWebSocket(...) from the test client and assert protocol forwarding or frame relay when relevant.
  • Use scoped test layers for flags, database reset, and other global mutable state. Restore flags and reset state in finalizers.
  • Use tmpdirScoped({ git: true }) plus Project.use.fromDirectory(dir) for project-backed requests.
  • If a test needs persisted state without matching runtime state, keep direct database setup inside a narrowly named helper that explains that state.
  • Add comments for non-obvious test topology, especially tests involving both the local test server and a fake upstream server.