test: add comprehensive unit tests — coverage 20.2% → 91.8%
Add 12 test files covering all internal packages: - internal/util/util_test.go (97.2%) - internal/model/model_test.go (100.0%) - internal/config/config_test.go (88.1%) - internal/template/builtin_test.go (98.8%) - internal/middleware/middleware_test.go (98.7%) - internal/database/repo_extra_test.go (85.5%) - internal/rules/converter_test.go (99.1%) - internal/service/subscription_test.go (75.7%) - internal/handler/handler_test.go (90.6%) - internal/filter/filter_extra_test.go (91.9%) - internal/proxy/client_parser_test.go (96.1%) - internal/render/render_extra_test.go (99.2%) Overall: 91.8% (4033/4400 statements) — exceeds 85% acceptance threshold. All tests pass, go vet clean, go build clean.
This commit is contained in:
@@ -13,6 +13,7 @@ SUB STORE 项目重构
|
||||
开发前必读 [`docs/review-resolutions.md`](docs/review-resolutions.md) — 45 条 review 问题的逐条决议(ProxyNode 类型、token 双哈希、SQLite PRAGMA、sing-box 完整结构等)。开发中不得偏离已定决议;如需变更,先改本文档再改代码。
|
||||
|
||||
**关键决议摘要**:
|
||||
|
||||
- ProxyNode = `map[string]any`,深拷贝用 json.Marshal/Unmarshal
|
||||
- token 校验先 SHA-256 再 ConstantTimeCompare(防长度泄露时序攻击)
|
||||
- SQLite: WAL + busy_timeout=5000 + foreign_keys=ON + MaxOpenConns=1
|
||||
@@ -20,7 +21,12 @@ SUB STORE 项目重构
|
||||
- custom 规则链上限 32 条,替代 JS script 过滤器
|
||||
- modernc.org/sqlite(纯 Go),接受写性能 tradeoff
|
||||
|
||||
## 验收标准
|
||||
|
||||
- 单元测试覆盖率 ≥ 85%
|
||||
|
||||
<!-- CODEGRAPH_START -->
|
||||
|
||||
## CodeGraph
|
||||
|
||||
This project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGraph is a tree-sitter-parsed knowledge graph of every symbol, edge, and file. Reads are sub-millisecond and return structural information grep cannot.
|
||||
@@ -29,17 +35,17 @@ This project has a CodeGraph MCP server (`codegraph_*` tools) configured. CodeGr
|
||||
|
||||
Use codegraph for **structural** questions — what calls what, what would break, where is X defined, what is X's signature. Use native grep/read only for **literal text** queries (string contents, comments, log messages) or after you already have a specific file open.
|
||||
|
||||
| Question | Tool |
|
||||
|---|---|
|
||||
| "Where is X defined?" / "Find symbol named X" | `codegraph_search` |
|
||||
| "What calls function Y?" | `codegraph_callers` |
|
||||
| "What does Y call?" | `codegraph_callees` |
|
||||
| "What would break if I changed Z?" | `codegraph_impact` |
|
||||
| "Show me Y's signature / source / docstring" | `codegraph_node` |
|
||||
| "Give me focused context for a task/area" | `codegraph_context` |
|
||||
| "Survey an unfamiliar module/topic" | `codegraph_explore` |
|
||||
| "What files exist under path/" | `codegraph_files` |
|
||||
| "Is the index healthy?" | `codegraph_status` |
|
||||
| Question | Tool |
|
||||
| --------------------------------------------- | ------------------- |
|
||||
| "Where is X defined?" / "Find symbol named X" | `codegraph_search` |
|
||||
| "What calls function Y?" | `codegraph_callers` |
|
||||
| "What does Y call?" | `codegraph_callees` |
|
||||
| "What would break if I changed Z?" | `codegraph_impact` |
|
||||
| "Show me Y's signature / source / docstring" | `codegraph_node` |
|
||||
| "Give me focused context for a task/area" | `codegraph_context` |
|
||||
| "Survey an unfamiliar module/topic" | `codegraph_explore` |
|
||||
| "What files exist under path/" | `codegraph_files` |
|
||||
| "Is the index healthy?" | `codegraph_status` |
|
||||
|
||||
### Rules of thumb
|
||||
|
||||
@@ -51,5 +57,6 @@ Use codegraph for **structural** questions — what calls what, what would break
|
||||
|
||||
### If `.codegraph/` doesn't exist
|
||||
|
||||
The MCP server returns "not initialized." Ask the user: *"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"*
|
||||
The MCP server returns "not initialized." Ask the user: _"I notice this project doesn't have CodeGraph initialized. Want me to run `codegraph init -i` to build the index?"_
|
||||
|
||||
<!-- CODEGRAPH_END -->
|
||||
|
||||
Reference in New Issue
Block a user