Add unit tests for Client and Auth

Create client_test.go with comprehensive tests using httptest.Server:
- TestNewClient_Defaults: verify default configuration
- TestNewClient_WithOptions: test functional options
- TestAuthenticate_Success: successful authentication flow
- TestAuthenticate_InvalidCredentials: 401 error handling
- TestAuthenticate_2FA: 2FA token support
- TestTokenRefresh_Auto: automatic token refresh on expiry
- TestTokenRefresh_Manual: manual token refresh
- TestCurrentUser: get current user information
- TestRetryLogic_429: retry on rate limiting
- TestRetryLogic_5xx: retry on server errors
- TestRetryLogic_ExhaustedRetries: max retries exceeded
- TestRetryLogic_ContextCancellation: respect context cancellation
- TestCalculateRetryDelay: exponential backoff calculation
- TestDefaultRetryConfig: verify default retry settings

Add testdata/auth/ fixtures:
- login_success.json
- current_user.json

All 14 tests pass.

Closes checkvist-api-8bn
This commit is contained in:
Oliver Jakoubek 2026-01-14 13:35:44 +01:00
commit 15cf18e2d8
4 changed files with 500 additions and 1 deletions

5
testdata/auth/current_user.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"id": 12345,
"username": "testuser",
"email": "test@example.com"
}