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:
@@ -24,30 +24,39 @@ type StubConcurrencyCache struct{}
|
||||
func (c StubConcurrencyCache) AcquireAccountSlot(_ context.Context, _ int64, _ int, _ string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) ReleaseAccountSlot(_ context.Context, _ int64, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) GetAccountConcurrency(_ context.Context, _ int64) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) IncrementAccountWaitCount(_ context.Context, _ int64, _ int) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) DecrementAccountWaitCount(_ context.Context, _ int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) GetAccountWaitingCount(_ context.Context, _ int64) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) AcquireUserSlot(_ context.Context, _ int64, _ int, _ string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) ReleaseUserSlot(_ context.Context, _ int64, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) GetUserConcurrency(_ context.Context, _ int64) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) IncrementWaitCount(_ context.Context, _ int64, _ int) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
@@ -59,6 +68,7 @@ func (c StubConcurrencyCache) GetAccountsLoadBatch(_ context.Context, accounts [
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) GetUsersLoadBatch(_ context.Context, users []service.UserWithConcurrency) (map[int64]*service.UserLoadInfo, error) {
|
||||
result := make(map[int64]*service.UserLoadInfo, len(users))
|
||||
for _, u := range users {
|
||||
@@ -66,6 +76,7 @@ func (c StubConcurrencyCache) GetUsersLoadBatch(_ context.Context, users []servi
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) GetAccountConcurrencyBatch(_ context.Context, accountIDs []int64) (map[int64]int, error) {
|
||||
result := make(map[int64]int, len(accountIDs))
|
||||
for _, id := range accountIDs {
|
||||
@@ -73,9 +84,11 @@ func (c StubConcurrencyCache) GetAccountConcurrencyBatch(_ context.Context, acco
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) CleanupExpiredAccountSlots(_ context.Context, _ int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubConcurrencyCache) CleanupStaleProcessSlots(_ context.Context, _ string) error {
|
||||
return nil
|
||||
}
|
||||
@@ -91,12 +104,15 @@ type StubGatewayCache struct{}
|
||||
func (c StubGatewayCache) GetSessionAccountID(_ context.Context, _ int64, _ string) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c StubGatewayCache) SetSessionAccountID(_ context.Context, _ int64, _ string, _ int64, _ time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubGatewayCache) RefreshSessionTTL(_ context.Context, _ int64, _ string, _ time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubGatewayCache) DeleteSessionAccountID(_ context.Context, _ int64, _ string) error {
|
||||
return nil
|
||||
}
|
||||
@@ -112,24 +128,31 @@ type StubSessionLimitCache struct{}
|
||||
func (c StubSessionLimitCache) RegisterSession(_ context.Context, _ int64, _ string, _ int, _ time.Duration) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) RefreshSession(_ context.Context, _ int64, _ string, _ time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) GetActiveSessionCount(_ context.Context, _ int64) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) GetActiveSessionCountBatch(_ context.Context, _ []int64, _ map[int64]time.Duration) (map[int64]int, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) IsSessionActive(_ context.Context, _ int64, _ string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) GetWindowCost(_ context.Context, _ int64) (float64, bool, error) {
|
||||
return 0, false, nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) SetWindowCost(_ context.Context, _ int64, _ float64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c StubSessionLimitCache) GetWindowCostBatch(_ context.Context, _ []int64) (map[int64]float64, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user