Repository navigation
test: add pkg/id edge-case coverage - #1014
Merged
Merged
Conversation
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).
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 26 |
| 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.
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.
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/id— small utility package providingSafeConcatName,SafeConcatNameMax, andToDockerImageName. It had no test file before this change.Issue found
pkg/idhad zero test coverage. Its functions have several non-obvious edge cases that were untested:SafeConcatNameMaxtruncates over-length names by keeping a prefix, inserting a-separator, and appending a 7-char sha256 hash suffix (total exactlymaxLen). The separator position (maxLen-8) and prefix-preservation behavior were not documented by any test.SafeConcatNameMaxstrips a trailing.before the hash separator (ReplaceAll(".-", "-")) when a name ends in a dot at the truncation boundary.ToDockerImageNamelowercases the input and strips any character outside[a-z0-9\-_].Change
Adds
pkg/id/id_test.gowith 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 exactlymaxLenis returned unchanged.TestSafeConcatNameMaxOverLimit— over-limit input is truncated to exactlymaxLen, the-separator sits at indexmaxLen-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/idpasses; only the known pre-existingpkg/gitTestRepoClone*failures remain (this change does not touchpkg/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.