refactor: Default examples and codegen to a test-local registry#38
Merged
refactor: Default examples and codegen to a test-local registry#38
Conversation
Generated blueprints now expose `NewRegistry()` and accept `RegisterBlueprints(reg *seedling.Registry)`, registering via `MustRegisterTo` so consumers default to a test-local registry instead of mutating the package-global one.
Each example now constructs its own *seedling.Registry per test, calls RegisterBlueprints(reg), and runs inserts via seedling.NewSession[T](reg) instead of touching the package-global registry with ResetRegistry / RegisterBlueprints(). Keeps t.Parallel() and large suites free of cross-test interference.
Update README Quick Start, package overview, guide, and seedling-gen / seedling-test-setup skills to teach the NewRegistry + NewSession[T](reg) pattern as the default. The package-global helpers remain available for snippets that focus on a single option.
Code Metrics Report
Details | | main (cb25711) | #38 (5b0ed33) | +/- |
|---------------------|----------------|---------------|-------|
+ | Coverage | 90.2% | 90.2% | +0.0% |
| Files | 57 | 57 | 0 |
| Lines | 3349 | 3352 | +3 |
+ | Covered | 3023 | 3026 | +3 |
- | Code to Test Ratio | 1:1.5 | 1:1.5 | -0.1 |
| Code | 8696 | 8706 | +10 |
+ | Test | 13176 | 13187 | +11 |
- | Test Execution Time | 24s | 25s | +1s |Code coverage of files in pull request scope (95.5% → 95.6%)
Reported by octocov |
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.
Summary
t.Parallel()and large-suite cross-test interferenceseedling.NewRegistry()+seedling.NewSession[T](reg)InsertOne[T],MustRegister,ResetRegistry, ...) are left in place; they remain useful for option-focused snippets and incremental migrationChanges
NewRegistry()constructor plusRegisterBlueprints(reg *seedling.Registry)and registers each blueprint viaseedling.MustRegisterTocmd/seedling-gentemplate assertions to pin the new helper signatures and theMustRegisterTo(reg, ...)call shapeexamples/*blueprint package now takes*seedling.Registryand registers viaMustRegisterTo; thequickstartpackage also gains aNewRegistry()helper that mirrors the generated shapesetupbuilds a fresh registry and returns it so calls go throughseedling.NewSession[T](reg).InsertOne(...)/.InsertMany(...)/.InsertManyE(...)instead of touchingResetRegistry()and the global defaultdoc.goregistration example, and the seedling-gen / seedling-test-setup skill notes aroundNewRegistry()+NewSession[T](reg)quickstartexample and theseedling-genscaffolding output to match the new generator shape