test(pkg/copy): cover copy and rename helpers - #1090
Open
devsy-app[bot] wants to merge 1 commit into
Open
Conversation
Add tests for the previously-uncovered pkg/copy helpers: File content/mode copy, Directory recursive copy of nested dirs and symlinks, CreateIfNotExists idempotency, RenameDirectory tree move, and parseUserSpec group stripping. Uses a mustReadFile helper to satisfy gosec G304 on test temp paths.
✅ Deploy Preview for images-devsy-sh canceled.
|
✅ Deploy Preview for devsydev canceled.
|
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 1 critical |
🟢 Metrics 35 complexity · 2 duplication
Metric Results Complexity 35 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 17:26
skevetter
added this pull request to the merge queue
Aug 17, 2026
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/copy(system/platform/utility category). Prior to this change,pkg/copy/copy_test.goonly coveredMkdirAllChownandExists. The package's core helpers —File,Directory,CreateIfNotExists,RenameDirectory, andparseUserSpec— had no test coverage.Issue found
The copy/rename helpers are widely used but lacked tests exercising their main code paths: single-file copy (content + mode), recursive directory copy (nested dirs and symlinks),
CreateIfNotExistsidempotency,RenameDirectorytree move, andparseUserSpecgroup stripping.Change
Add focused tests in
pkg/copy/copy_test.go:TestCreateIfNotExistsIsIdempotent— creates a dir, then re-runs on the existing path.TestFileCopiesContentAndMode— verifies copied content and file mode.TestDirectoryCopiesNestedDirAndFile— recursive copy of a nested dir + child file.TestDirectoryCopiesSymlink— a symlink inside the source tree is reproduced at the destination.TestRenameDirectoryMovesTreeAndRemovesSource— tree is moved and source removed.TestParseUserSpecStripsGroup— theuser:groupform resolves to the user only.A
mustReadFilehelper (with a//nosec G304annotation) reads test temp paths to satisfy gosec without weakening the rule for production code. File modes use secure permissions (0o600/0o750).No behavioral change — test-only addition.
Verification
task cli:format— clean.task cli:lint:ci— 0 new issues.task cli:test— allpkg/copytests pass. (Pre-existing, unrelated failures inpkg/gitTestRepoClone*onorigin/mainare not touched by this change.)Self-improvement note
Findings persisted to the running automation via the automation service's agentic memory (not the repo).
This PR was created by an AI agent as part of an automated daily package review job.