test: cover GetHTTPPath branches - #1043
Merged
Merged
Conversation
Add tests for gitcredentials.GetHTTPPath, which had no coverage, exercising all branches: current-path override, useHttpPath disabled (empty), useHttpPath enabled (parsed repository path), host-only repository URL (no path), invalid repository URL error, and per-host config scoping.
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 6 |
| Duplication | 2 |
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.
skevetter
marked this pull request as ready for review
August 17, 2026 05:57
|
Tick the box to add this pull request to the merge queue (same as
|
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/gitcredentials(SSH/git/credentials category)Issue found
GetHTTPPathhad zero test coverage despite being a production code pathused by
pkg/agent/tunnelserverto resolve host git credentials(
tunnelserver.resolveHostGitCredentials). It has three distinct branches plusan error path, none of which were exercised:
CurrentPathprovided → returned as-is (short-circuit).useHttpPathnot set/disabled → returns"".useHttpPath = true→ parses the workspace repository URL and returns thepath component.
parse workspace repositoryerror.Change
Added 6 focused tests for
GetHTTPPathinpkg/gitcredentials/gitcredentials_test.go,mirroring the existing test style (temp HOME +
.gitconfigviaGIT_CONFIG_NOSYSTEM):TestGetHTTPPath_ReturnsCurrentPathWhenProvided— branch 1.TestGetHTTPPath_EmptyWhenUseHttpPathDisabled— branch 2 (default).TestGetHTTPPath_ReturnsRepositoryPathWhenUseHttpPathEnabled— branch 3.TestGetHTTPPath_EmptyPathWhenRepositoryHasNoPath— branch 3 edge: host-only URL.TestGetHTTPPath_ErrorOnInvalidRepositoryURL— branch 4 error path.TestGetHTTPPath_PerHostScopedConfigOnly—useHttpPathset for a different hostmust not apply (credential config is per
protocol://host).No behavioral change — test-only addition. Repeated string literals extracted to
constants to satisfy
goconstin CI lint.Verification performed
task cli:format— clean.task cli:lint:ci— 0 issues.task cli:test—pkg/gitcredentialspasses (ok ... coverage: 60.3%).The only failure is
pkg/git(TestRepoClone*), a known pre-existing staleassertion on
origin/mainunrelated to this change (this PR does not touchpkg/git).This PR was created by an AI agent as part of an automated daily package review job.