Files
user-system/internal/service/captcha_service_test.go
Your Name 108ee462d3 test: add AuthService and CaptchaService unit tests
AuthService Tests (22 functions):
Password Strength:
- GetPasswordStrength_Empty: empty password
- GetPasswordStrength_OnlyLowercase: lowercase only
- GetPasswordStrength_OnlyUppercase: uppercase only
- GetPasswordStrength_OnlyDigits: digits only
- GetPasswordStrength_OnlySpecial: special chars only
- GetPasswordStrength_TwoTypes: two character types
- GetPasswordStrength_ThreeTypes: three character types
- GetPasswordStrength_FourTypes: all character types
- GetPasswordStrength_Unicode: unicode handling

LoginRequest.GetAccount:
- GetAccount_Nil: nil request
- GetAccount_Empty: empty request
- GetAccount_Account: account field
- GetAccount_Username: username field
- GetAccount_Email: email field
- GetAccount_Phone: phone field
- GetAccount_Priority: field priority
- GetAccount_Trimmed: whitespace trimming
- GetAccount_EmptyAfterTrim: whitespace only

CaptchaService Tests (15 functions):
- Generate_Success: captcha generation
- Verify_CorrectAnswer: verification logic
- Verify_EmptyID: empty ID validation
- Verify_EmptyAnswer: empty answer validation
- Verify_NonExistent: non-existent captcha
- VerifyOneTimeUse: one-time use
- ValidateCaptcha_Success: validation success
- ValidateCaptcha_EmptyID: empty ID error
- ValidateCaptcha_EmptyAnswer: empty answer error
- MultipleGeneration: unique IDs
- Verify_CaseInsensitive: case handling
- Generate: basic generation
- Verify: basic verification
- ValidateCaptcha: basic validation
- VerifyWithoutDelete: test helper

Coverage:
- AuthService password validation: ~100%
- CaptchaService: ~85%+
- All service tests pass
2026-05-30 14:54:36 +08:00

4.3 KiB