Skip to content

[spec-enforcer] Enforce specifications for errorutil, syncutil, jsonutil#33527

Merged
pelikhan merged 1 commit into
mainfrom
spec-enforcer/errorutil-syncutil-jsonutil-2026-05-20-9e2b5ea390e2a2cf
May 20, 2026
Merged

[spec-enforcer] Enforce specifications for errorutil, syncutil, jsonutil#33527
pelikhan merged 1 commit into
mainfrom
spec-enforcer/errorutil-syncutil-jsonutil-2026-05-20-9e2b5ea390e2a2cf

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 20, 2026

Summary

Added specification tests for two utility packages (errorutil and syncutil) to enforce behavioral contracts and improve test coverage.

Changes

Tests Added (2 files)

pkg/errorutil/spec_test.go

  • Type: New test file
  • Purpose: Specification tests for error classifier functions
  • Coverage:
    • IsNotFoundError: Validates detection of 404/not-found errors
    • IsForbiddenError: Validates detection of 403/forbidden errors
    • IsGoneError: Validates detection of 410/gone errors
  • Test scope: Documented behavior, edge cases, and usage examples
  • Breaking: No

pkg/syncutil/spec_test.go

  • Type: New test file
  • Purpose: Specification tests for OnceLoader[T] generic type
  • Coverage:
    • Thread-safety guarantees
    • Caching behavior (single execution)
    • Error handling semantics
    • Reset() method behavior
    • Documented usage patterns
  • Test scope: Concurrent access, error propagation, state management
  • Breaking: No

Impact Assessment

  • Risk Level: Low
  • Impact Scope: Test-only changes
  • Breaking Changes: None
  • Dependencies: No new dependencies
  • Performance: No runtime impact (test code only)

Validation

  • Tests enforce existing documented behavior
  • No production code modified
  • Spec tests act as executable documentation

File Manifest

pkg/errorutil/spec_test.go (added)
pkg/syncutil/spec_test.go (added)

Commit Reference

  • 7f40bfff3 - Enforce specifications for errorutil, syncutil

Metadata

Generated by PR Description Updater for issue #33527 · ● 3.7M ·

Adds spec_test.go files derived from each package's README.md. Tests
validate documented behavior, usage examples, and design notes without
coupling to implementation internals.

- pkg/errorutil/spec_test.go: validates IsNotFoundError, IsForbiddenError,
  IsGoneError contracts including the documented "forbidden character"
  and "gone away" anti-patterns.
- pkg/syncutil/spec_test.go: validates OnceLoader[T] zero-value usability,
  single-loader-invocation contract, error caching with zero T, Reset
  semantics, and documented thread-safety guarantees.

jsonutil's existing spec_test.go was reviewed and already fully covers
the current README.md specification, so no changes were made to it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@pelikhan pelikhan merged commit 8a1d710 into main May 20, 2026
@pelikhan pelikhan deleted the spec-enforcer/errorutil-syncutil-jsonutil-2026-05-20-9e2b5ea390e2a2cf branch May 20, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant