[test-improver] Improve tests for httputil package#7546
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[test-improver] Improve tests for httputil package#7546github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Cover all branches of ComputeRetryAfter in github_http.go: - zero time → default 60s - past time → default 60s (secs < 1 branch) - future time → delay with 1s safety buffer - far future → clamped to 3600s maximum - just above max → still clamped to 3600s Brings internal/httputil coverage from 86.8% to 100%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
File Analyzed
internal/httputil/httputil_test.gointernal/httputilImprovements Made
1. Increased Coverage
Added
TestComputeRetryAfterto cover the previously untestedComputeRetryAfterfunction ingithub_http.go, which was the sole coverage gap in the package.secs < 1branch)assert.InDeltaused to tolerate scheduling jitter)Previous Coverage: 86.8%
New Coverage: 100.0%
Improvement: +13.2%
2. Better Testing Patterns
t.Parallel()for all subtests consistent with existing test styleassert.InDeltafor the timing-sensitive case to avoid flakiness from scheduling jitterTest Execution
All tests pass:
Why These Changes?
ComputeRetryAftercomputes theRetry-Afterdelay for rate-limited GitHub API responses. It has four distinct code branches (zero time, past time, within-range future, and over-max future) but had zero test coverage. The function is called when GitHub returns aX-RateLimit-Resetheader, making it important for correct retry behaviour.Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
index.crates.ioSee Network Configuration for more information.