test: cover third-party backend routing and model rewrite (#74)#79
Merged
Conversation
#74 shipped the third-party-backend feature (per-account upstream/modelMap/ models) with no tests. Add coverage for both surfaces: - Model-ownership routing in AccountManager: ownership is inert until some account declares a `models` list; an owned model routes only to owning accounts; the [Nm] suffix is stripped when matching; a Claude model claims no owner so Claude accounts stay eligible; the third-party account acts as a priority fallback; an owned model whose only owner is unavailable selects nothing; two accounts can co-own a model. - Request-body model rewrite (server.rewriteModel, now exported for tests): maps a known model, updates the byte length so Content-Length can be corrected, and passes through unchanged for an unmapped model, a non-JSON body, or a body with no model field. 163 tests pass, lint clean. No behavior change beyond exporting rewriteModel. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Follow-up to #74, which shipped the third-party-backend feature (per-account
upstream/modelMap/models) with no tests. Addstest/third-party-backend.test.jscovering both surfaces.Model-ownership routing (
AccountManager)modelslist.[Nm]suffix is stripped when matching, so a bare model name still routes to its owner.Request-body model rewrite (
server.rewriteModel)Content-Lengthcan be corrected (validates the fix inforwardRequest).modelfield.rewriteModelis nowexported fromserver.jsfor the unit test (mirrorsreadWithIdleTimeout). No behavior change.163 tests pass, lint clean.
🤖 Generated with Claude Code