Skip to content

test: cover GetHTTPPath branches - #1043

Merged
skevetter merged 3 commits into
mainfrom
pkg-ssh-git/gitcredentials-gethttppath-tests
Aug 18, 2026
Merged

test: cover GetHTTPPath branches#1043
skevetter merged 3 commits into
mainfrom
pkg-ssh-git/gitcredentials-gethttppath-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/gitcredentials (SSH/git/credentials category)

Issue found

GetHTTPPath had zero test coverage despite being a production code path
used by pkg/agent/tunnelserver to resolve host git credentials
(tunnelserver.resolveHostGitCredentials). It has three distinct branches plus
an error path, none of which were exercised:

  1. CurrentPath provided → returned as-is (short-circuit).
  2. useHttpPath not set/disabled → returns "".
  3. useHttpPath = true → parses the workspace repository URL and returns the
    path component.
  4. Invalid repository URL → returns a parse workspace repository error.

Change

Added 6 focused tests for GetHTTPPath in pkg/gitcredentials/gitcredentials_test.go,
mirroring the existing test style (temp HOME + .gitconfig via GIT_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_PerHostScopedConfigOnlyuseHttpPath set for a different host
    must not apply (credential config is per protocol://host).

No behavioral change — test-only addition. Repeated string literals extracted to
constants to satisfy goconst in CI lint.

Verification performed

  • task cli:format — clean.
  • task cli:lint:ci0 issues.
  • task cli:testpkg/gitcredentials passes (ok ... coverage: 60.3%).
    The only failure is pkg/git (TestRepoClone*), a known pre-existing stale
    assertion on origin/main unrelated to this change (this PR does not touch
    pkg/git).

This PR was created by an AI agent as part of an automated daily package review job.

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.
@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 4f83b58
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a83dab5c5c522000850e452

@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 4f83b58
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a83dab5f012d70008ba4236

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 2 duplication

Metric Results
Complexity 6
Duplication 2

View in Codacy

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.

Run reviewer

TIP This summary will be updated as you push new changes.

@skevetter
skevetter marked this pull request as ready for review August 17, 2026 05:57
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@skevetter
skevetter merged commit 3619174 into main Aug 18, 2026
135 of 137 checks passed
@skevetter
skevetter deleted the pkg-ssh-git/gitcredentials-gethttppath-tests branch August 18, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant