test(file): cover IsLocalDir branches - #1061
Open
devsy-app[bot] wants to merge 3 commits into
Open
Conversation
pkg/file had no tests. Add table-style coverage for IsLocalDir: existing dir, existing file, relative path resolves to absolute, and non-existent path returns the name unchanged. No behavioral change.
✅ Deploy Preview for images-devsy-sh ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for devsydev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 18 |
| 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/file— system/platform category. This package had no tests at all.Issue found
pkg/fileshippedfile.go,file_supported.go, andfile_unsupported.gowith zero test coverage. The most widely used function,IsLocalDir, is consumed across the codebase (pkg/devcontainer/helpers.go,pkg/workspace/machine.gox2,pkg/workspace/workspace.gox2,cmd/internal/get_workspace_name.go) yet had no tests guarding its contract: returns(true, absPath)for an existing local path and(false, name)(name unchanged) otherwise.Change
Add
pkg/file/file_test.gowith focused tests forIsLocalDir:TestIsLocalDirExistingDirectory— existing directory returns(true, abs)where the returned name equalsfilepath.Abs(dir).TestIsLocalDirExistingFile— an existing regular file (not just a dir) is also treated as local and resolved to its absolute path.TestIsLocalDirRelativePathResolvesToAbsolute— a relative existing path returnstrueand an absolute resolved name (usest.Chdirso the working directory is isolated).TestIsLocalDirNonExistentPathReturnsNameUnchanged— a path that does not exist returns(false, name)with the name passed through verbatim.No behavioral change — tests only.
Verification
task cli:format— clean.task cli:lint:ci— 0 new issues (checked againstorigin/mainvia--new-from-patch).task cli:test—pkg/filepasses; the only failure is the known pre-existingpkg/gitTestRepoClone*stale-assertion failure onorigin/main, unrelated to this change (this change did not touchpkg/git).go test -v ./pkg/file/— all 4 tests pass.This PR was created by an AI agent as part of an automated daily package review job.