Skip to content

test: add pkg/id edge-case coverage - #1014

Merged
skevetter merged 3 commits into
mainfrom
pkg-system-platform/id-tests
Aug 13, 2026
Merged

skevetter merged 3 commits into
mainfrom
pkg-system-platform/id-tests

Conversation

@devsy-app

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

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/id — small utility package providing SafeConcatName, SafeConcatNameMax, and ToDockerImageName. It had no test file before this change.

Issue found

pkg/id had zero test coverage. Its functions have several non-obvious edge cases that were untested:

  • SafeConcatNameMax truncates over-length names by keeping a prefix, inserting a - separator, and appending a 7-char sha256 hash suffix (total exactly maxLen). The separator position (maxLen-8) and prefix-preservation behavior were not documented by any test.
  • SafeConcatNameMax strips a trailing . before the hash separator (ReplaceAll(".-", "-")) when a name ends in a dot at the truncation boundary.
  • ToDockerImageName lowercases the input and strips any character outside [a-z0-9\-_].

Change

Adds pkg/id/id_test.go with edge-case coverage (no behavioral change to production code):

  • TestSafeConcatName — single, multiple, and empty-part joins.
  • TestSafeConcatNameMaxUnderLimit — under-limit input is returned unchanged.
  • TestSafeConcatNameMaxExactLimit — input at exactly maxLen is returned unchanged.
  • TestSafeConcatNameMaxOverLimit — over-limit input is truncated to exactly maxLen, the - separator sits at index maxLen-8, and the prefix is preserved.
  • TestSafeConcatNameMaxStripsTrailingDot — a trailing . at the truncation boundary is stripped (no ".-" remains).
  • TestSafeConcatNameMaxIsDeterministic — the hash suffix is stable across calls.
  • TestToDockerImageName — lowercasing, invalid-char stripping, allowed-separator preservation, and empty input.
  • TestToDockerImageNameOnlyLowercase — guarantees no uppercase runes survive.

Verification

  • task cli:format — clean.
  • task cli:lint:ci — 0 new issues.
  • task cli:test — pkg/id passes; only the known pre-existing pkg/git TestRepoClone* failures remain (this change does not touch pkg/git).
  • go test ./pkg/id/ -v — all 9 sub-tests PASS.

This PR was created by an AI agent as part of an automated daily package review job.

pkg/id had no tests. Add edge-case coverage for SafeConcatName, SafeConcatNameMax (under/exact/over limit, trailing-dot strip, determinism), and ToDockerImageName (lowercasing, invalid-char strip, separators, empty).
@netlify

netlify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

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

@netlify

netlify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh ready!

Name Link
🔨 Latest commit ab6d38c
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a7df321c756d2000849a170
😎 Deploy Preview https://deploy-preview-1014--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.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 26 complexity · 0 duplication

Metric Results
Complexity 26
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.

skevetter and others added 2 commits August 12, 2026 14:27
Remove the stray blank line inside the const block in id_test.go so gci reports the file as properly formatted. Lint fix only; no behavior change.

This commit was created by an AI agent (OpenHands) on behalf of the user.
@skevetter
skevetter merged commit 59e2baf into main Aug 13, 2026
67 checks passed
@skevetter
skevetter deleted the pkg-system-platform/id-tests branch August 13, 2026 22:17
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