fix: resolve go vet warnings in webhook_handler_test.go

- Replace raw http.DefaultClient.Do(req) with doRequestWithCheck helper
- Helper function now handles errors via t.Fatalf
- Content-Type only set when body is non-nil

docs: update REAL_PROJECT_STATUS.md with 2026-04-09 verification

Go vet: 0 warnings
This commit is contained in:
2026-04-09 19:01:08 +08:00
parent a3e090e821
commit 71d4dcc441
2 changed files with 98 additions and 75 deletions

View File

@@ -1,5 +1,60 @@
# REAL PROJECT STATUS
## 2026-04-09 最低验证矩阵 & Service层测试增强
### 本轮验证结果 (2026-04-09)
| 验证项 | 状态 | 说明 |
|--------|------|------|
| `go build ./cmd/server` | ✅ | 构建成功 |
| `go test ./internal/... -short` | ✅ | 全部38个packages通过 |
| `go vet ./internal/...` | ✅ | 无警告 |
| `npm run build` (frontend) | ✅ | 构建成功 |
### 本轮修复内容
- **go vet 警告修复**: `webhook_handler_test.go` 中的 `resp` 错误检查问题
- 添加 `doRequestWithCheck` 辅助函数统一错误处理
- 所有 HTTP 请求现通过辅助函数执行,自动处理错误
- **Service层测试增强**: 新增6个测试文件
- `webhook_service_test.go`: `isPrivateIP`, `isSafeURL`, `computeHMAC` 安全函数
- `request_metadata_test.go`: Context元数据函数
- `classified_error_test.go`: 错误类型测试
- `config_defaults_test.go`: 配置默认值测试
- `email_config_test.go`: 邮箱配置测试
- `auth_runtime_test.go`: `isUserNotFoundError` 测试
### 覆盖率状态
| 模块 | 覆盖率 |
|------|--------|
| api/handler | 15.6% |
| api/middleware | 21.5% |
| auth | 28.1% |
| auth/providers | **80.6%** |
| cache | **77.3%** |
| config | **85.2%** |
| database | **74.1%** |
| repository | 47.2% |
| middleware (internal) | **65.4%** |
| service | 14.7% |
### Govulncheck 漏洞状态
| 漏洞 | 影响 | 状态 |
|------|------|------|
| GO-2026-4866 (crypto/x509) | 需要 Go 1.26.2 修复 | ⚠️ 当前 Go 1.26.1 |
| GO-2026-4865 (html/template) | 需要 Go 1.26.2 修复 | ⚠️ 当前 Go 1.26.1 |
**说明**: Go 1.26.2 下载失败(网络问题),待环境恢复后升级。
### 提交记录
- `a3e090e` - test: add service layer unit tests for webhook/metadata/error/config
- `a6a0e58` - test: add more UserHandler tests for RBAC coverage
- `3ffce94` - test: add WebhookHandler tests
## 2026-04-02 E2E 测试扩展
### E2E 测试场景扩展