test: add integration tests for lazy registry promotion pattern#1117
Merged
test: add integration tests for lazy registry promotion pattern#1117
Conversation
Adds 10 tests verifying the lazy registry promotion contract introduced by PR #1089 and fixed by PR #1116: Category 1 (8 tests, fresh instances): Documents the registry invariant that get() returns undefined for lazy entries and ensureTypeLoaded() must be called first to promote them. Covers all four registries (vault, datastore, driver, report). Category 2 (2 tests, global singletons): Verifies that resolveVaultType() and resolveDatastoreType() promote lazy entries before returning, so callers can safely use get() afterwards. These tests would have caught the PR #1089 regression — they fail without the ensureTypeLoaded() calls added in PR #1116. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
Well-structured integration tests that document and guard the lazy registry promotion invariant. The two-category approach (registry-level invariants + consumer regression tests) is thoughtful — Category 1 tests the contract itself, Category 2 catches the actual bug that shipped.
Blocking Issues
None.
Suggestions
- Global singleton mutation in Category 2 tests: The tests call
setTypeLoader()on the globalvaultTypeRegistryanddatastoreTypeRegistrysingletons. This is mitigated by UUID-based type names, but if a future test depends on the previously-set loader, it would silently get the test's fake loader instead. Consider adding a cleanup step (e.g., restoring the original loader) via a try/finally or Deno test sanitizer. Low risk given the current test suite, so non-blocking.
LGTM — good regression guards for the lazy promotion pattern.
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
Adds regression guard tests for the lazy registry promotion pattern introduced by PR #1089 and fixed by PR #1116. These tests would have caught the
ensureTypeLoaded()regression before it reached UAT.Category 1: Registry invariant tests (8 tests, fresh instances)
Documents the contract that
get()returnsundefinedfor lazy entries andensureTypeLoaded()must be called to promote them. One positive + one negative test for each of the four registries (vault, datastore, driver, report). These pass regardless of the fix — they test the registry itself, not consumers.Category 2: Consumer regression tests (2 tests, global singletons)
Verifies that
resolveVaultType()andresolveDatastoreType()promote lazy entries so callers can safely useget()afterwards. The critical assertion:Without PR #1116:
resolveVaultType()callshas()(returns true for lazy) and returns true, but never callsensureTypeLoaded()— soget()returnsundefinedand the test fails.With PR #1116:
resolveVaultType()callsensureTypeLoaded()first, promoting the lazy entry — soget()returns the type and the test passes.Test Plan
deno run test integration/lazy_registry_promotion_test.ts— 10 passed, 0 faileddeno check— cleandeno lint— cleandeno fmt --check— clean🤖 Generated with Claude Code