Repository navigation
test(download): cover parseGithubURL branches - #1046
Merged
Merged
Conversation
Add table-driven tests for parseGithubURL covering latest/tagged releases and rejection cases. pkg/download previously had zero coverage for this branching path parser.
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 9 |
| Duplication | 0 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
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.
Package reviewed
pkg/download(system/platform category).Issue found
parseGithubURLis a branching path parser that extracts the GitHub org, repo, asset file name, and optional tag from a release download URL. It had zero test coverage — none of its valid paths (latest release, tagged release, with/without leading slash) or rejection paths (too few/many segments, missingreleasessegment, unknown middle segment, latest withoutdownload, empty path, root slash) were exercised. A regression in the parser would silently break release-asset downloads with no test to catch it.Change
Add table-driven tests in
pkg/download/download_test.go:TestParseGithubURLValid— latest release, tagged release, and both without a leading slash, asserting the parsed org/repo/file/tag.TestParseGithubURLInvalid— too few segments, too many segments, missingreleasessegment, unknown middle segment, latest withoutdownload, empty path, and root slash, asserting a non-nil error.Shared literals are extracted as constants (
testGithubOrg,testGithubRepo,testGithubFile,testGithubTag) to satisfygoconst, and the single test function was split into valid/invalid groups to satisfyfunlen. No production code changed.Verification
task cli:lint:ci— 0 issues.task cli:test— all pass except the known pre-existingpkg/gitTestRepoClone*failures (stale assertion on origin/main, unrelated to this change which touches onlypkg/download).go test -run TestParseGithubURL|TestSanitizeURL ./pkg/download/...— PASS.This PR was created by an AI agent as part of an automated daily package review job.