Test: Improve coverage for auth, cron, factory, run, and rest packages#3296
Open
NitinKumar004 wants to merge 2 commits intogofr-dev:developmentfrom
Open
Test: Improve coverage for auth, cron, factory, run, and rest packages#3296NitinKumar004 wants to merge 2 commits intogofr-dev:developmentfrom
NitinKumar004 wants to merge 2 commits intogofr-dev:developmentfrom
Conversation
Add table-driven tests for uncovered functions: - EnableBasicAuthWithFunc (0% -> 100%) - EnableAPIKeyAuthWithFunc (0% -> 100%) - EnableBasicAuth with no credentials (81.8% -> 100%) - handleStartupHooks including context.Canceled path (28.6% -> 100%) - rest.go add() with REQUEST_TIMEOUT edge cases (71.4% -> 85.7%) Overall package coverage: 82.4% -> 83.1%
…thods - errParsing.Error() both branches (66.7% -> 100%) - errOutOfRange.Error() direct test - job.tick with nil sec field edge cases - noopRequest interface methods - New() with invalid gRPC and HTTP port configs - initMetricsServer with default port - startGRPCServer registered and not-registered paths (20% -> 100%) - startSubscriptionManager with no subscriptions - PUT/POST/DELETE/PATCH route registration
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.
Summary
Added table-driven unit tests to improve coverage for core framework files:
auth.go,cron.go,factory.go,run.go, andrest.go. Only test files modified — no production code changes.Coverage improvements
EnableBasicAuthWithFuncEnableAPIKeyAuthWithFuncEnableBasicAutherrParsing.Error()handleStartupHooksstartGRPCServerrest.go add()Overall package coverage: 82.4% → 83.5%
Tests added
Test_EnableBasicAuthWithFunc— table-driven: no auth, correct creds, wrong credsTest_EnableAPIKeyAuthWithFunc— table-driven: no key, valid key, invalid keyTest_EnableBasicAuth_NoCredentials— edge case with empty credentialsTestHandleStartupHooks— table-driven: no hooks, success, errorTestHandleStartupHooks_ContextCanceled— context.Canceled pathTest_add_RequestTimeout— table-driven: valid, empty, invalid, negative timeoutTestErrParsing_Error— both branches (with/without base)TestErrOutOfRange_Error— error message formatTestJob_tick_SecNilAndNonZeroSec— nil sec field edge casesTestNoopRequest— all interface methodsTestNew_InvalidGRPCPort/TestNew_InvalidHTTPPort— factory error pathsTestInitMetricsServer_DefaultPort— default metrics portTestStartGRPCServer_Registered/TestStartGRPCServer_NotRegistered— both pathsTestStartSubscriptionManager_NoSubscriptions— empty subscriptionsTest_HTTPMethods— table-driven: PUT, POST, DELETE, PATCHTest plan
pkg/gofrtest suite passes