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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user