test: assert boot initialization and clear cleanup in unit.test.mjs#83
Merged
Conversation
- Verify a booted client is actually initialized from the supplied options: the API url is wired into the API client and the auth provider is a VaultTokenAuth carrying the configured token. - Verify clear() releases instance resources by spying on the instance's close() (which cancels the auth-refresh timer) and asserting it is invoked once before the instance is removed. Signed-off-by: kurok <22548029+kurok@users.noreply.github.com>
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.
Addresses the 2 GitHub AI code-quality findings on
test/unit.test.mjs.Findings addressed
Boot test didn't verify initialization from config. The
"should boot a new VaultClient instance" test only checked
instanceOf. It now asserts the options are actually wired into theinstance:
client.__api.__config.urlequalsbootOpts.api.urlclient.__authis aVaultTokenAuth(honorsauth.type)client.__auth.__tokenequalsbootOpts.auth.config.tokenClear test didn't verify resource cleanup.
VaultClient.clear()calls
instance.close(), which cancels the auth token-refresh timer(the resource that otherwise keeps the event loop alive). The test now
spies on the instance's
close()and asserts it is invoked exactlyonce when
clear()is called, before the instance is removed.Notes
Rather than the suggested speculative property-name fallback chains
(
client?.api?.url ?? client?.config?.api?.url ?? …) and adispose/close/destroyheuristic, these assertions target theclient's real internals — matching the existing conventions already used
in
test/VaultClient.test.mjs(private-field access,sinon.spy(i, 'close')).Verification
npm run test:unit— 136 passing. (npm testalso runstest/e2e/*,which require a live Vault at
127.0.0.1:8200and are unrelated to this change.)