Skip to content

test(pkg/copy): cover copy and rename helpers - #1090

Open
devsy-app[bot] wants to merge 1 commit into
mainfrom
pkg-system-platform/copy-tests
Open

test(pkg/copy): cover copy and rename helpers#1090
devsy-app[bot] wants to merge 1 commit into
mainfrom
pkg-system-platform/copy-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/copy (system/platform/utility category). Prior to this change, pkg/copy/copy_test.go only covered MkdirAllChown and Exists. The package's core helpers — File, Directory, CreateIfNotExists, RenameDirectory, and parseUserSpec — 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), CreateIfNotExists idempotency, RenameDirectory tree move, and parseUserSpec group 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 — the user:group form resolves to the user only.

A mustReadFile helper (with a //nosec G304 annotation) 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 — all pkg/copy tests pass. (Pre-existing, unrelated failures in pkg/git TestRepoClone* on origin/main are 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.

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

netlify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

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

@netlify

netlify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit b83c529
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a82f5916e70bf0008ba0702

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 critical

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 critical

View in Codacy

🟢 Metrics 35 complexity · 2 duplication

Metric Results
Complexity 35
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 17:26
@skevetter
skevetter added this pull request to the merge queue Aug 17, 2026
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.

0 participants