Add SetSeed method to MockGenerator and SchemaRenderer for Deterministic Output - #450
Merged
daveshanley merged 2 commits intoAug 25, 2025
Merged
Conversation
…tic output - Add SetSeed() method to SchemaRenderer to allow setting custom random seed - Add SetSeed() method to MockGenerator that delegates to underlying renderer - Replace global rand usage with instance-based *rand.Rand in SchemaRenderer - Update all rand.* calls to use instance-specific random source - Add comprehensive tests for deterministic behavior with same/different seeds - Maintains full backward compatibility with existing API This enables deterministic mock generation for testing purposes while keeping existing random behavior by default.
- Initialize rand field in createSchemaRenderer() test helper - Add missing math/rand import to schema_renderer_test.go This fixes the panic that occurred when tests created empty SchemaRenderer instances without initializing the new rand field.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #450 +/- ##
==========================================
- Coverage 99.67% 99.67% -0.01%
==========================================
Files 169 169
Lines 24546 24551 +5
==========================================
+ Hits 24467 24470 +3
- Misses 74 76 +2
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
califlower
marked this pull request as ready for review
August 11, 2025 19:32
califlower
force-pushed
the
add-seed-support-mock-generator
branch
from
August 11, 2025 19:53
1b67723 to
079f82a
Compare
Contributor
Author
|
fixes #454 |
daveshanley
approved these changes
Aug 25, 2025
daveshanley
left a comment
Member
There was a problem hiding this comment.
LGTM! Thanks! this is a nice upgrade.
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.
This enables deterministic mock generation for testing purposes while keeping existing random behavior by default.
Some background, the random behavior was convenient but made certain generation scenarios a bit hard to test. If this isn't something you think is needed lmk it's not a big deal either way