Skip to content

tests: add unit tests for OpenRouterProvider with mocked client#3043

Merged
Salazareo merged 1 commit into
mainfrom
DS/2980
May 9, 2026
Merged

tests: add unit tests for OpenRouterProvider with mocked client#3043
Salazareo merged 1 commit into
mainfrom
DS/2980

Conversation

@Salazareo
Copy link
Copy Markdown
Member

Mocks both the OpenAI SDK and axios at the module boundary, boots a real PuterServer for the wired MeteringService, and clears the kv-cached model list between tests. Covers construction (default and custom apiBaseUrl), model catalog (axios fetch + kv caching, openrouter: prefix on ids, openrouter/auto filtering), the openrouter/auto disallow gate, request shape (prefix stripping, usage:{include:true}, stream options, retry-without-max_tokens on context-length errors, rethrow on unrelated errors), both cost-calculator branches (cost-bearing vs per-token fallback) for non-stream and streaming, and moderation.

closes #2980

Mocks both the OpenAI SDK and axios at the module boundary, boots a
real PuterServer for the wired MeteringService, and clears the
kv-cached model list between tests. Covers construction (default and
custom apiBaseUrl), model catalog (axios fetch + kv caching, openrouter:
prefix on ids, openrouter/auto filtering), the openrouter/auto disallow
gate, request shape (prefix stripping, usage:{include:true}, stream
options, retry-without-max_tokens on context-length errors, rethrow on
unrelated errors), both cost-calculator branches (cost-bearing vs
per-token fallback) for non-stream and streaming, and moderation.

closes #2980
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 39.94%
⬆️ +0.36%
7059 / 17674
🔵 Statements 39.08%
⬆️ +0.32%
7447 / 19051
🔵 Functions 42.63%
⬆️ +0.44%
1273 / 2986
🔵 Branches 28.86%
⬆️ +0.31%
4052 / 14040
File CoverageNo changed files found.
Generated in workflow #103 for commit d3c567e by the Vitest Coverage Report Action

@Salazareo Salazareo merged commit 91ecf54 into main May 9, 2026
4 checks passed
@Salazareo Salazareo deleted the DS/2980 branch May 10, 2026 21:29
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.

[Tests] Add unit tests for OpenRouterProvider with mocked client

1 participant