test: check request errors and stop asserting PathRewrite on /v1/models

/v1/models is served from config by ServeHTTP (task 2.5) so it never reaches
routing; the rewrite test now uses a non-reserved path.
This commit is contained in:
Story Crater Bot
2026-08-19 23:55:42 -07:00
parent c8c656046a
commit 8feee6754b
9 changed files with 183 additions and 67 deletions
+16 -4
View File
@@ -76,7 +76,10 @@ func TestBodyBasedDispatch(t *testing.T) {
reasoningCalled = false
ornithCalled = false
requestBody := `{"model":"reasoning","messages":[{"role":"user","content":"hi"}]}`
resp, _ := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(requestBody))
resp, err := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(requestBody))
if err != nil {
t.Fatalf("request failed: %v", err)
}
resp.Body.Close()
if !reasoningCalled {
@@ -151,7 +154,10 @@ func TestBodyPreservedUnmodified(t *testing.T) {
// Send a request with specific body content
originalBody := `{"model":"reasoning","stream":true,"messages":[{"role":"user","content":"hello world"}],"temperature":0.7}`
resp, _ := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(originalBody))
resp, err := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(originalBody))
if err != nil {
t.Fatalf("request failed: %v", err)
}
resp.Body.Close()
if string(receivedBody) != originalBody {
@@ -249,7 +255,10 @@ func TestUnknownModelReject(t *testing.T) {
defer server.Close()
requestBody := `{"model":"unknown-model","messages":[]}`
resp, _ := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(requestBody))
resp, err := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(requestBody))
if err != nil {
t.Fatalf("request failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusBadRequest {
@@ -300,7 +309,10 @@ func TestMissingModelField(t *testing.T) {
defer server.Close()
requestBody := `{"messages":[]}`
resp, _ := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(requestBody))
resp, err := http.Post(server.URL+"/v1/chat/completions", "application/json", strings.NewReader(requestBody))
if err != nil {
t.Fatalf("request failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusBadRequest {