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)
This commit is contained in:
2026-04-17 20:43:50 +08:00
parent 0d66aa0423
commit 582ad7a069
136 changed files with 19010 additions and 8544 deletions

View File

@@ -21,30 +21,30 @@ func NewThemeService(themeRepo *repository.ThemeConfigRepository) *ThemeService
// CreateThemeRequest 创建主题请求
type CreateThemeRequest struct {
Name string `json:"name" binding:"required"`
LogoURL string `json:"logo_url"`
FaviconURL string `json:"favicon_url"`
PrimaryColor string `json:"primary_color"`
SecondaryColor string `json:"secondary_color"`
Name string `json:"name" binding:"required"`
LogoURL string `json:"logo_url"`
FaviconURL string `json:"favicon_url"`
PrimaryColor string `json:"primary_color"`
SecondaryColor string `json:"secondary_color"`
BackgroundColor string `json:"background_color"`
TextColor string `json:"text_color"`
CustomCSS string `json:"custom_css"`
CustomJS string `json:"custom_js"`
IsDefault bool `json:"is_default"`
TextColor string `json:"text_color"`
CustomCSS string `json:"custom_css"`
CustomJS string `json:"custom_js"`
IsDefault bool `json:"is_default"`
}
// UpdateThemeRequest 更新主题请求
type UpdateThemeRequest struct {
LogoURL string `json:"logo_url"`
FaviconURL string `json:"favicon_url"`
PrimaryColor string `json:"primary_color"`
SecondaryColor string `json:"secondary_color"`
LogoURL string `json:"logo_url"`
FaviconURL string `json:"favicon_url"`
PrimaryColor string `json:"primary_color"`
SecondaryColor string `json:"secondary_color"`
BackgroundColor string `json:"background_color"`
TextColor string `json:"text_color"`
CustomCSS string `json:"custom_css"`
CustomJS string `json:"custom_js"`
Enabled *bool `json:"enabled"`
IsDefault *bool `json:"is_default"`
TextColor string `json:"text_color"`
CustomCSS string `json:"custom_css"`
CustomJS string `json:"custom_js"`
Enabled *bool `json:"enabled"`
IsDefault *bool `json:"is_default"`
}
// CreateTheme 创建主题
@@ -64,14 +64,14 @@ func (s *ThemeService) CreateTheme(ctx context.Context, req *CreateThemeRequest)
Name: req.Name,
LogoURL: req.LogoURL,
FaviconURL: req.FaviconURL,
PrimaryColor: req.PrimaryColor,
SecondaryColor: req.SecondaryColor,
PrimaryColor: req.PrimaryColor,
SecondaryColor: req.SecondaryColor,
BackgroundColor: req.BackgroundColor,
TextColor: req.TextColor,
CustomCSS: req.CustomCSS,
CustomJS: req.CustomJS,
IsDefault: req.IsDefault,
Enabled: true,
TextColor: req.TextColor,
CustomCSS: req.CustomCSS,
CustomJS: req.CustomJS,
IsDefault: req.IsDefault,
Enabled: true,
}
// 如果设置为默认,先清除其他默认