Your Name
af37de9eda
test: add Export, Settings, and Theme handler tests (49 test functions)
...
ExportHandler Tests (16 functions):
Export:
- ExportUsers_Success: basic export
- ExportUsers_WithFormat: CSV and Excel formats
- ExportUsers_WithFields: selective field export
- ExportUsers_WithFilter: keyword and status filtering
- ExportUsers_NonAdmin: permission check
- ExportUsers_Unauthorized: auth check
Import:
- ImportUsers_Success: CSV import
- ImportUsers_NoFile: empty file validation
- ImportUsers_InvalidFormat: unsupported format
- ImportUsers_NonAdmin: permission check
Templates:
- GetImportTemplate_Success: template download
- GetImportTemplate_CSV: CSV template
- GetImportTemplate_Excel: Excel template
- GetImportTemplate_Unauthorized: auth check
Response headers:
- ExportResponse_ContentType: content-type header
- ExportResponse_ContentDisposition: attachment disposition
SettingsHandler Tests (3 functions):
- GetSettings_Success: retrieve system settings
- GetSettings_NonAdmin: admin-only access
- GetSettings_Unauthorized: auth requirement
ThemeHandler Tests (30 functions):
CRUD:
- ListThemes_Success: list enabled themes
- ListAllThemes_Success: list all themes
- GetTheme_Success: get theme by ID
- GetTheme_NotFound: 404 handling
- GetTheme_InvalidID: ID validation
- CreateTheme_Success: create new theme
- CreateTheme_MissingName: required field validation
- CreateTheme_NonAdmin: admin-only restriction
- UpdateTheme_Success: modify theme
- UpdateTheme_NotFound: 404 handling
- UpdateTheme_InvalidID: ID validation
- DeleteTheme_Success: remove theme
- DeleteTheme_NotFound: 404 handling
- DeleteTheme_NonAdmin: admin-only restriction
Default/Active themes:
- GetDefaultTheme_Success: retrieve default
- GetActiveTheme_Success: retrieve active (public)
- SetDefaultTheme_Success: set default theme
- SetDefaultTheme_NotFound: 404 handling
- SetDefaultTheme_InvalidID: ID validation
- SetDefaultTheme_NonAdmin: admin-only
Security:
- CRUD_FullFlow: complete theme workflow
Coverage:
- ExportHandler: 0% → ~80%+
- SettingsHandler: 0% → ~85%+
- ThemeHandler: 0% → ~80%+
- All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +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