16 Commits

Author SHA1 Message Date
xfy
74f08466d4 fix(lint): 修复 goconst 和未使用导入问题
- 将重复的 "static" 字符串提取为 staticType 常量
- 移除 compression_e2e_test.go 中未使用的 fmt 导入

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 17:38:14 +08:00
xfy
dbc74939d8 fix(e2e): 修复 E2E 测试使用正确的 API
- 使用 StartLolly 替代 StartLollyContainer
- 简化 compression_e2e_test.go 的辅助函数
- 移除函数内的 import 语句

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 17:16:22 +08:00
xfy
7c67c93ca6 fix(e2e): 修复 compression_e2e_test.go 的 import 语法错误
将函数内的 import 语句移到文件顶部的 import 块中。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 17:11:47 +08:00
xfy
5574339d28 test: 完善测试覆盖率和 E2E 测试场景
Phase 1: 单元测试补充
- 新增 config/loader_test.go,覆盖配置加载、include 合并、循环检测
- 补充 cache/cache_test.go,测试 RefreshCachedAt、DeleteByPatternWithMethod
- 补充 handler/static_test.go,测试 SetExpires、setCacheHeaders、parseExpires

Phase 2: E2E 测试扩展
- 新增 ratelimit_e2e_test.go,测试请求限流功能
- 新增 compression_e2e_test.go,测试 Gzip 压缩功能
- 新增 access_e2e_test.go,测试 IP 访问控制
- 新增 rewrite_e2e_test.go,测试 URL 重写和重定向

覆盖率提升: 82.3% -> 83.1%
E2E 测试用例: ~84 -> ~104 (+20)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 17:06:55 +08:00
xfy
1be6480f5c feat(e2e): 添加重试机制和测试覆盖率支持
- 新增 testutil/retry.go 提供重试工具函数
  - WaitForCondition: 等待条件满足
  - WaitForNoError: 等待操作无错误
  - WaitForHealthy: 等待服务健康
  - Poll: 简化轮询接口
- 新增 testutil/retry_test.go 单元测试
- container.go 添加 Logs() 方法用于诊断
- Makefile 新增 test-e2e-cover 和 test-e2e-short 目标
- 重构 healthcheck 和 loadbalance 测试使用重试机制

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 16:07:17 +08:00
xfy
2122067efb docs: 更新 AGENTS.md 文档,添加新模块说明
- 更新所有 AGENTS.md 时间戳至 2026-04-24
- 添加 converter、e2e、testutil 模块文档
- 更新 README.md:nginx 配置导入、stale 缓存功能说明
- 更新项目统计:132 Go 文件,157 测试文件

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 18:24:31 +08:00
xfy
fa74074bc7 refactor(e2e): 简化 HTTP/2 测试为 HTTPS 连接测试
- 移除 HTTP/2 协议特定测试(流多路复用、头部压缩、服务器推送等)
- 重命名测试函数 TestE2EHTTP2* → TestE2EHTTPS*
- 使用 testutil.CreateTLSClient 简化客户端创建
- 移除 golang.org/x/net/http2 依赖

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 18:02:36 +08:00
xfy
e145f1b080 test(http2): 添加 HTTP/2 E2E 和 TLS 集成测试
- 添加 HTTP/2 协议协商、流多路复用、头部压缩 E2E 测试
- 添加 TLS 握手、ALPN 协商、HTTP/1.1 回退集成测试

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 17:20:21 +08:00
xfy
2ffcfd782b style(e2e): 清理代码格式和未使用的导入
- 删除 loadbalance_e2e_test.go 中未使用的 encoding/json 导入
- 删除 ssl_e2e_test.go 中未使用的 net/http 导入
- 格式化 testutil/config.go 中的结构体字段对齐
- 为多个文件添加末尾换行符

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 15:36:42 +08:00
xfy
9eaa77478a test(e2e): 添加缓存、健康检查、负载均衡和 WebSocket E2E 测试
扩展 SSL E2E 测试覆盖更多场景。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 14:51:25 +08:00
xfy
0790c5a9e4 test(e2e/testutil): 扩展测试工具包
添加配置生成、常量定义、测试设置、SSL 和 WebSocket 工具函数。
重构 container.go 支持函数式选项模式配置容器。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 14:51:11 +08:00
xfy
76ab9bcb24 refactor(e2e): 统一 E2E 测试以 lolly 为被测系统
- 将 StartNginxContainer 重命名为 StartMockBackend,明确其作为模拟后端的用途
- proxy_e2e_test.go: 所有测试使用 lolly 作为代理,nginx 作为后端
- ssl_e2e_test.go: 移除 nginx 容器测试,简化为 lolly SSL 功能测试
- static_e2e_test.go: 所有测试使用 lolly 作为静态文件服务器

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 10:25:56 +08:00
xfy
be58730c52 test(e2e): 添加代理和静态文件 E2E 测试
- proxy_e2e_test.go: 测试代理转发、负载均衡
- static_e2e_test.go: 测试静态文件服务、目录索引

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 09:35:31 +08:00
xfy
e5b494c058 refactor(e2e): 简化 SSL E2E 测试代码
使用 testutil 工具包重构,减少重复代码

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 09:35:25 +08:00
xfy
5d38d9ab44 test(e2e): 添加 E2E 测试工具包和配置
- 添加 testutil 容器管理工具(lolly/nginx)
- 添加测试配置文件(basic/proxy/ssl)
- 添加测试用 SSL 证书

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 09:35:19 +08:00
xfy
dd6b61f987 test(e2e): 添加 SSL/TLS E2E 测试框架
- e2e_test.go: E2E 测试基础设施初始化
- ssl_e2e_test.go: SSL 握手、TLS 版本、加密套件、mTLS 测试
- 使用 testcontainers-go 进行容器化测试

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-22 14:59:21 +08:00