10 Commits

Author SHA1 Message Date
Your Name
e735f74c23 test: add domain constants tests
Add tests for domain constant values:
- Status constants (active, disabled, error, etc.)
- Role constants (admin, user)
- Platform constants (anthropic, openai, gemini, etc.)
- Account type constants (oauth, apikey, bedrock, etc.)
- Redeem type constants
- PromoCode status constants
- Adjustment type constants
- Subscription type/status constants
- Model mapping verification
2026-05-29 21:04:33 +08:00
Your Name
23bfed3b61 test: add domain LoginType constants test
Add test for LoginType enum constants:
- LoginTypePassword (1)
- LoginTypeEmailCode (2)
- LoginTypeSMSCode (3)
- LoginTypeOAuth (4)
2026-05-29 20:29:08 +08:00
Your Name
7a20548204 test: add social account domain tests
- Add SocialAccountStatus constants tests
- Add ExtraData Value/Scan tests
- Add SocialAccount ToInfo and field tests
2026-05-29 17:52:16 +08:00
Your Name
871bc79598 test: add repository and domain tests
- Add pagination result tests (internal/repository/pagination.go)
- Add Gemini drive client factory test (internal/repository/gemini_drive_client.go)
- Add scanSingleRow contract tests (internal/repository/sql_scan.go)
- Add DefaultThemeConfig test (internal/domain/theme.go)

Coverage improvements:
- repository: 75.8%
- domain: 21.1%
2026-05-29 16:59:05 +08:00
Your Name
ffcd820fed test: add domain model tests
- Add Announcement.IsActiveAt tests (nil, status, time range)
- Add TableName tests for all domain models
- Domain package coverage: 9.2% -> 16.3%
- Overall coverage: 54.1% -> 54.2%
2026-05-29 15:35:03 +08:00
Your Name
9f0eefd2f5 test: improve coverage for pagination and domain packages
- Add comprehensive cursor pagination tests (95.7% coverage)
- Add domain helper functions tests (StrPtr, DerefStr)
- Add Gender and UserStatus constants tests
- Add User model tests (TableName, default values)
- Overall coverage improved from 53.2% to 53.5%
2026-05-29 14:57:49 +08:00
8095307d82 fix: P0/P1 security and quality fixes
P0-01: Add ESCAPE clause to LIKE queries in operation_log.go and device.go
P0-02: Add atomic Increment to L1Cache and L2Cache interfaces
P0-07: Add TOTP verification step after password login
P1-01: Sanitize error messages in error.go middleware
P1-03: Remove err.Error() from export error messages
P1-04: Add error return to CountByResultSince in login_log.go
P1-05: Add transactional DeleteCascade to RoleRepository
P1-06: Add PasswordChangedAt tracking for JWT token invalidation
P1-07: Wrap theme SetDefault in database transaction
P1-08: Use config values for database pool parameters
P1-09: Add rows.Err() checks in social_account_repo.go
P1-10: Validate sortOrder with map in user.go ORDER BY
P1-11: Add GORM tags to Announcement struct
P1-15: Add pageSize upper limit (100) to device and log handlers
2026-04-18 15:33:12 +08:00
582ad7a069 test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
2026-04-17 20:43:50 +08:00
8655b39b03 test: 完善方案一业务逻辑测试和方案二规模测试
方案一(业务逻辑正确性测试):
- 修复 SocialAccount.CreatedAt/UpdatedAt NULL 扫描问题(改为 *time.Time 指针)
- 修复 OPLOG_003~006 数据隔离(改用唯一前缀+Search方法隔离)
- 修复 DEV_008 设备列表测试(改用UserID过滤器隔离)
- 修复并发测试 cache=private → cache=shared(SQLite连接共享)
- 新增 testEnv 隔离架构(独立DB + 独立 httptest.Server)

方案二(真实数据规模测试):
- 新增 LatencyStats P99/P95 百分位统计采集器
- 全部 16 个测试迁移至 newIsolatedDB(独立内存DB,WAL模式)
- 关键查询添加 P99 多次采样统计(UL/LL/DV/DS/PR/AUTH/OPLOG)
- 新增 CONC_SCALE_001~003 并发压测(50-100 goroutine)
- 删除旧 setupScaleTestDB 死代码
- 双阈值体系:SQLite本地宽松阈值 vs PostgreSQL生产严格目标

共计 84 测试通过(68 业务逻辑 + 16 规模测试)
2026-04-07 07:23:29 +08:00
dcc1f186f8 feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers 2026-04-02 11:19:50 +08:00