Repository navigation
test(ssh): cover GetUser config parsing - #956
Merged
Merged
Conversation
Add unit tests for GetUser in pkg/ssh/config.go, which previously had no direct test coverage. Tests cover: default root user when config is missing, reading a configured User directive, default when the host section lacks a User line, default when no section exists for the workspace, include path taking precedence over the primary config, empty path resolving to ~/.ssh/config, and unquoting of quoted User values. No behavioral change.
✅ Deploy Preview for images-devsy-sh canceled.
|
✅ Deploy Preview for devsydev canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 9 |
| Duplication | 9 |
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 9, 2026 16:52
Signed-off-by: GitHub <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.
Package reviewed
pkg/ssh(SSH/git/credentials category — scope:pkg/ssh,pkg/gitsshsigning,pkg/gitcredentials,pkg/credentials,pkg/pty,pkg/shell,pkg/dotfiles,pkg/gpg).Issue found
GetUserinpkg/ssh/config.goresolves the SSHUserdirective for a workspace host but had no direct unit-test coverage. The parsing logic (host-section matching,Includeprecedence, empty-path defaulting to~/.ssh/config, quoted-value unquoting, and therootfallback) was exercised only indirectly, so regressions in any of those branches could land unnoticed.Change
Add
pkg/ssh/config_getuser_test.gowith 7 focused unit tests covering the previously-untested paths:TestGetUser_ReturnsRootWhenConfigMissing— defaultrootwhen no config file exists.TestGetUser_ReturnsConfiguredUser— reads theUserdirective from the workspace host section.TestGetUser_ReturnsRootWhenNoUserDirective— default when the host section exists but lacks aUserline.TestGetUser_ReturnsRootWhenHostSectionAbsent— default when the config has no section for the workspace.TestGetUser_IncludePathTakesPrecedence— when an include path is supplied, the user is read from it rather than the primary config.TestGetUser_EmptyPathResolvesHome— an empty path resolves to~/.ssh/config(the same defaultConfigureSSHConfigwrites to).TestGetUser_UnquotesQuotedUser— a quotedUservalue (without inner spaces) is unquoted, as written by SSH clients that quote values containing special characters.No production code is changed — tests only.
Verification performed
task cli:format— clean (no formatting changes).task cli:lint:ci— 0 new issues.task cli:test—pkg/sshtests pass (7/7 new tests pass). The only failures are the known pre-existing ones unrelated to this change:pkg/git(TestRepoClone*, stale assertion on origin/main) ande2e(TestRunE2ETests).This PR was created by an AI agent as part of an automated daily package review job.