Skip to content

test(file): cover IsLocalDir branches - #1061

Open
devsy-app[bot] wants to merge 3 commits into
mainfrom
pkg-system-platform/file-islocaldir-tests
Open

test(file): cover IsLocalDir branches#1061
devsy-app[bot] wants to merge 3 commits into
mainfrom
pkg-system-platform/file-islocaldir-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/file — system/platform category. This package had no tests at all.

Issue found

pkg/file shipped file.go, file_supported.go, and file_unsupported.go with zero test coverage. The most widely used function, IsLocalDir, is consumed across the codebase (pkg/devcontainer/helpers.go, pkg/workspace/machine.go x2, pkg/workspace/workspace.go x2, 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.go with focused tests for IsLocalDir:

  • TestIsLocalDirExistingDirectory — existing directory returns (true, abs) where the returned name equals filepath.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 returns true and an absolute resolved name (uses t.Chdir so 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 against origin/main via --new-from-patch).
  • task cli:testpkg/file passes; the only failure is the known pre-existing pkg/git TestRepoClone* stale-assertion failure on origin/main, unrelated to this change (this change did not touch pkg/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.

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

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit 2a966c5
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a829f2a9a64010008bdd001
😎 Deploy Preview https://deploy-preview-1061--images-devsy-sh.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev ready!

Name Link
🔨 Latest commit 2a966c5
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a829f2aa3cf6f0008e52cb1
😎 Deploy Preview https://deploy-preview-1061--devsydev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 18 complexity · 0 duplication

Metric Results
Complexity 18
Duplication 0

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.

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