Skip to content

test: coverage wave 2 — utility packages toward 95% - #268

Merged
saadqbal merged 1 commit into
developfrom
test/coverage-wave2-utils
Jul 14, 2026
Merged

test: coverage wave 2 — utility packages toward 95%#268
saadqbal merged 1 commit into
developfrom
test/coverage-wave2-utils

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Wave 2 of the coverage push (now on merged develop), driving the small self-contained packages with real, measured tests:

PackageBeforeAfter
pathutil91.7%100%
slug94.3%97.1%
schema84.5%94.4%plateau
config75.8%93.4%plateau

pathutil + slug clear 95%. config + schema plateau just under — and it's worth being explicit about why, because it's the crux of "95% for all":

Both are blocked only by by-construction-uncoverable branches:

  • config: the atomic-write's defensive I/O errors (Chmod/Write/Close on a just-created temp file) + a provably-unreachable MarshalIndent check (a *Config of strings/maps can't fail to marshal).
  • schema: NewV1Validator's "embedded schema is malformed" defense-in-depth (can't happen — the CI drift check + go:embed guarantee a valid schema) + ValidateYAML's "jsonschema/v6 always returns a *ValidationError" defensive else.

Reaching those last statements would mean faking the filesystem / removing idiomatic error handling purely for the number — deliberately not done. Everything reachable in both packages is now covered.

Test plan

  • make ci green. All additions are behavior-asserting (not number-padding); the one redundant test I initially wrote (it added 0 coverage) was removed.

🤖 Generated with Claude Code


Note

Low Risk
Test-only additions with no changes to production logic or runtime behavior.

Overview
Adds five*_coverage_test.go files—no production code changes—as wave 2 of pushing utility packages toward ~95% coverage.

internal/config exercises Current/Profile lazy map behavior, default vs missing-home Dir/Path, v2 load failures and nil profiles, v1 migrate parse errors, Save when home is unset or config.json is a non-empty directory, and clearAll error propagation (via TRACEBLOC_CONFIG_DIR / empty HOME).

internal/pathutil, internal/schema, and internal/slug add targeted cases for ExpandHome fallbacks, error-chain helpers and FormatErrors tie-break / nil flatten, and Derive empty-input, fallback, collision, and max-length truncation paths.

Tests assert observable behavior rather than padding metrics; remaining gaps in config/schema are documented as hard-to-hit defensive branches.

Reviewed by Cursor Bugbot for commit bc754ea. Bugbot is set up for automated code reviews on this repo. Configure here.

First wave-2 batch (post-merge of the coverage sprint), driving the small
self-contained packages up with real, measured tests:
- pathutil: 91.7% -> 100% (ExpandHome's no-home + unknown-~user fallbacks)
- slug: 94.3% -> 97.1% (Derive fallback + collision-truncation branches)
- schema: 84.5% -> 94.4% (unwrap/errors_as helpers; FormatErrors same-Path
tiebreak; flatten nil-guard)
- config: 75.8% -> 93.4% (Current; Profile nil-map; Dir/Path/Load/Save/clearAll
error branches via cleared HOME; Load 2nd-unmarshal; migrateV1 error;
Save rename-onto-dir)
pathutil + slug clear 95%. config + schema plateau just under, blocked ONLY by
by-construction-uncoverable branches: config's atomic-write defensive I/O
(Chmod/Write/Close on a fresh temp file) + the unreachable MarshalIndent check;
schema's NewV1Validator "embedded schema malformed" defense-in-depth (can't
happen — CI drift check + go:embed guarantee it) + ValidateYAML's "jsonschema/v6
always returns a *ValidationError" defensive else. Reaching those means faking
the filesystem / removing idiomatic error handling — deliberately not done.
make ci green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodkaLukasWodka self-assigned this Jul 14, 2026
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit bc754ea. Configure here.

@saadqbalsaadqbal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Verified the specific ones against source — slug.Derive (raw-fallback when both slugify empty, the -2 collision suffix, and the max-length truncation keeping len ≤ MaxLabelLength) and config.Current/Profile/Dir error arms all line up. Clean branch-coverage additions across the utility pkgs.

@saadqbal
saadqbal merged commit d2fa0ab into developJul 14, 2026
22 checks passed
@saadqbal
saadqbal deleted the test/coverage-wave2-utils branch July 14, 2026 10:42
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@LukasWodka@saadqbal