Skip to content

test: assert boot initialization and clear cleanup in unit.test.mjs#83

Merged
kurok merged 1 commit into
masterfrom
fix/ai-findings-unit-test-2
Jun 9, 2026
Merged

test: assert boot initialization and clear cleanup in unit.test.mjs#83
kurok merged 1 commit into
masterfrom
fix/ai-findings-unit-test-2

Conversation

@kurok

@kurok kurok commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Addresses the 2 GitHub AI code-quality findings on test/unit.test.mjs.

Findings addressed

  1. 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 the
    instance:

    • client.__api.__config.url equals bootOpts.api.url
    • client.__auth is a VaultTokenAuth (honors auth.type)
    • client.__auth.__token equals bootOpts.auth.config.token
  2. Clear 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 exactly
    once 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 a
dispose/close/destroy heuristic, these assertions target the
client'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 test also runs test/e2e/*,
which require a live Vault at 127.0.0.1:8200 and are unrelated to this change.)

- 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>
@kurok kurok requested a review from wRLSS as a code owner June 9, 2026 08:31
@kurok kurok merged commit d31d726 into master Jun 9, 2026
12 checks passed
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.

1 participant