Skip to content

test(builder): add golden tests, fuzz, benchmarks, and doc comments - #10

Merged
thisisibrahimd merged 1 commit into
mainfrom
testing
Sep 1, 2026
Merged

thisisibrahimd merged 1 commit into
mainfrom
testing

Conversation

@thisisibrahimd

Copy link
Copy Markdown
Owner

Summary

Comprehensive testing improvements for the pkg/builder package — the core code generator for Jsonnet Kubernetes libraries.

Builder Test Improvements

  • Converted all tests to table-driven format with golden files (108 golden files across 18 test types)
  • Added missing type tests: ArithType (Add/Sub/Div/Mul/Mod), SprintfType, Doc, CommentType, RequiredArgType, CallArg
  • Added fuzz tests: FuzzEscapeKey, FuzzMarshal, FuzzIndent, FuzzDedent
  • Added property-based tests: dedent/indent inverse invariant, escapeKey validity, Marshal type correctness
  • Added benchmarks: 7 benchmarks covering Object rendering, Marshal, ArgsString, CallChain, Doc, EscapeKey
  • Added JSON validation: all golden output validated via go-jsonnet/formatter as syntactically valid Jsonnet
  • Added Go doc comments to all public types and functions following go.dev/doc/comment

Results

Metric Before After
Coverage (builder) 89.8% 96.6%
Coverage (docsonnet) — 100%
Golden files 0 108
Fuzz tests 0 4
Benchmarks 0 7
Property tests 0 5

New Files

  • pkg/builder/TESTING.md — testing guide
  • pkg/builder/fuzz_test.go — fuzz tests
  • pkg/builder/property_test.go — property-based tests
  • pkg/builder/benchmark_test.go — performance benchmarks
  • pkg/builder/doc_test.go — Doc type tests
  • pkg/builder/operators_test.go — ArithType + SprintfType tests
  • pkg/builder/comments_test.go — CommentType + RequiredArg + CallArg tests
  • pkg/builder/testdata/ — 108 golden fixture files

Convert all builder package tests to table-driven format with golden
files. Add fuzz tests for escapeKey, Marshal, indent, and dedent.
Add property-based tests for invariants. Add benchmarks for rendering
performance. Add Go doc comments to all public types and functions.

- 108 golden files across 18 test types
- Coverage increased from 89.8% to 96.6%
- All golden output validated as syntactically valid Jsonnet
- New test files: fuzz, property, benchmark, doc, operators, comments
@thisisibrahimd
thisisibrahimd merged commit 8cd9b2b into main Sep 1, 2026
1 check passed
Sign up for free to 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.

1 participant