http/TEST.md

27 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 测试报告
## 测试场景覆盖
- **基础请求**: 验证了使用 `Get` 获取 JSON 响应并通过 `To[T]` 进行泛型绑定的功能。
- **本地服务器**: 验证了客户端与本地测试服务器的交互。
- **H2C 支持**: 验证了 H2C (HTTP/2 Cleartext) 的兼容性。
- **手动请求**: 验证了通过 `ManualDo` 进行精细化控制的流式请求。
- **文件下载**: 验证了使用 `Download` 进行并发分段下载的功能。
- **多部分表单 (Multipart)**: 验证了使用流式 `io.Pipe``Multipart` 发送,以及多类型、多值字段的支持。
- **表单与映射**: 验证了使用 `Form`, `map[string]string`, `map[string][]string`, 和 `map[string][]any` 自动转为正确的 `application/x-www-form-urlencoded``application/json`
## 性能测试结果 (Benchmark)
```
goos: darwin
goarch: amd64
pkg: apigo.cc/go/http
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkGet-16 13606 79289 ns/op
```
## 🛡️ 鲁棒性防御 (Robustness)
- **可选参数与验证**`POST`/`PUT` 请求自动前置验证 `Multipart` 文件的安全路径,并受安全沙箱控制。
- **JS 错误调用栈**JS 桥接层改用具名导出并使用 `jsmod.MakeError` 包裹错误,确保 JS 抛出异常时携带准确的 Go 运行时堆栈。
## 测试覆盖率
- **整体覆盖率**: 56.5% of statements