Skip to content

test: improve CEL validator coverage#214

Merged
sivchari merged 2 commits intosivchari:mainfrom
wafuwafu13:test/improve-cel-coverage
Feb 23, 2026
Merged

test: improve CEL validator coverage#214
sivchari merged 2 commits intosivchari:mainfrom
wafuwafu13:test/improve-cel-coverage

Conversation

@wafuwafu13
Copy link
Contributor

@wafuwafu13 wafuwafu13 commented Jan 22, 2026

Description

Add comprehensive test cases for CEL validation:

  • 8 test cases in TestCELValidation covering age boundaries, empty name, is_active false state
  • TestCELValidationNil for nil pointer handling

This improves coverage of marker_cel_validator.go and strengthens edge case handling.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Quality Checklist

Before submitting this pull request, ensure your contribution meets these quality standards:

Code Quality

  • Code passes make golangci-lint without errors
  • All tests pass: make test
  • Code follows existing patterns and conventions
  • No hard-coded values (use constants or configuration)
  • Error messages are clear and actionable

Testing Requirements

  • Golden tests created and passing (internal/analyzers/govalid/testdata/)
  • Unit tests implemented with boundary value testing (test/unit/)
  • Benchmark tests comparing against popular validation libraries (test/benchmark/)
  • All test files generated: cd test && go generate

Performance Standards

  • Zero allocations in validation logic (verified via benchmarks)
  • Performance improvement over existing validation libraries (minimum 2x faster)
  • Benchmark results added to test/benchmark/README.md

Documentation

  • README.md updated with new marker documentation
  • Code includes appropriate comments and examples
  • Validator usage examples provided

Integration

  • Validator scaffold generated with make generate-validator MARKER=yourmarker
  • Registry files automatically updated
  • Binary rebuilt and installed: go install ./cmd/govalid/

Final Verification

  • All GitHub Actions CI checks pass
  • No breaking changes to existing functionality
  • Contribution follows project license requirements

Additional Notes

https://app.codecov.io/gh/sivchari/govalid/blob/main/test%2Fmarker_cel_validator.go

Related Issues

#132

Add comprehensive test cases for CEL validation:
- 8 test cases in TestCELValidation covering age boundaries, empty name, is_active false state
- TestCELValidationNil for nil pointer handling

This improves coverage of marker_cel_validator.go and strengthens edge case handling.
@wafuwafu13 wafuwafu13 requested a review from sivchari as a code owner January 22, 2026 13:25
Copy link
Owner

@sivchari sivchari left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Owner

@sivchari sivchari left a comment

Choose a reason for hiding this comment

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

Sorry, left one nit

if err == nil {
t.Error("expected error for nil CEL, got nil")
}
if err.Error() != "input CEL is nil" {
Copy link
Owner

Choose a reason for hiding this comment

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

Why don't you use ErrNilCEL to assert error ?
You can write it like this

if !errors.Is(err, test.ErrNilCEL) {}

@github-actions
Copy link
Contributor

🔍 Fuzz Testing Results

FuzzIsValidEmail: Passed (15 seconds)
FuzzIsValidUUID: Passed (15 seconds)
FuzzIsValidURL: Passed (15 seconds)


🎉 All fuzz tests passed! The changes don't introduce any obvious issues.

Note: This was a quick 15-second fuzz test. More extensive testing runs on the main branch.

@github-actions
Copy link
Contributor

📊 Coverage Report

Total Coverage: 83.2%

Details

Run make coverage locally to see detailed coverage by function.

Copy link
Owner

@sivchari sivchari left a comment

Choose a reason for hiding this comment

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

Thanks again.

@sivchari sivchari merged commit 3c893ab into sivchari:main Feb 23, 2026
8 checks passed
@github-actions github-actions bot mentioned this pull request Feb 18, 2026
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.

2 participants