test: add comprehensive config loading tests from environment variables - #28
Merged
Merged
Conversation
Add comprehensive test suite covering all scenarios for loadConfigFromEnv(): Suite 1: OAuth URL Defaults (1 test) - Verifies AuthURL and TokenURL have correct hardcoded values for both AniList and MAL - Tests fix for issue #26 Suite 2: Single Missing Required Fields (4 tests) - Tests each required field individually Suite 3: Multiple Missing Required Fields (4 tests) - Tests combinations: all missing, 3 missing (4 cases), 2 missing (6 cases), one site missing Suite 4: Optional Fields (4 tests) - Tests with no optional fields, all optional fields, and optional ClientSecret behavior Suite 5: Edge Cases (5 tests) - Tests PORT/OAUTH_PORT precedence, legacy env var behavior Suite 6: Integration Tests (oauth_test.go, 3 tests) - Tests OAuth URL generation through public API (GetAuthURL, NewOAuth) - Verifies full URL includes host (not just query params) Total: 21 new test functions, 648+ lines added
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add comprehensive test suite covering all scenarios for
loadConfigFromEnv().Summary
This PR adds 21 new test functions (648+ lines) comprehensively testing configuration loading from environment variables.
Test Suites
Suite 1: OAuth URL Defaults (1 test)
TestLoadConfigFromEnv_OAuthURLsHaveDefaultsAuthURLandTokenURLhave correct hardcoded values for both AniList and MyAnimeListSuite 2: Required Fields - Single Missing (4 tests)
TestLoadConfigFromEnv_MissingAnilistClientIDTestLoadConfigFromEnv_MissingAnilistUsernameTestLoadConfigFromEnv_MissingMALClientIDTestLoadConfigFromEnv_MissingMALUsernameSuite 3: Required Fields - Multiple Missing (4 tests)
TestLoadConfigFromEnv_AllRequiredFieldsMissingTestLoadConfigFromEnv_ThreeRequiredFieldsMissing(4 subtests)TestLoadConfigFromEnv_TwoRequiredFieldsMissing(6 subtests)TestLoadConfigFromEnv_OneSiteConfigMissing(2 subtests)Suite 4: Optional Fields (4 tests)
TestLoadConfigFromEnv_NoOptionalFields- verifies defaultsTestLoadConfigFromEnv_AllOptionalFieldsSetTestLoadConfigFromEnv_AnilistClientSecretOptionalTestLoadConfigFromEnv_MALClientSecretOptionalSuite 5: Edge Cases (5 tests)
TestLoadConfigFromEnv_PORTPrecedence- OAUTH_PORT vs PORTTestLoadConfigFromEnv_OnlyPORTSetTestLoadConfigFromEnv_LegacyAnilistSecretFallback- verifies legacy env vars don't work inloadConfigFromEnv()TestLoadConfigFromEnv_LegacyMALSecretFallbackTestLoadConfigFromEnv_NewSecretPrecedenceSuite 6: Integration Tests via Public API (3 tests)
TestGetAuthURL_EnvConfigIncludesHost- verifies full URL includes host (not just query params like?client_id=...)TestGetAuthURL_EnvConfigIncludesHost/MyAnimeList_URL_has_correct_hostTestNewOAuth_EnvConfigEndpoints- verifies OAuth endpoint configurationTest plan