MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestInfer_InvalidJSON400

Function TestInfer_InvalidJSON400

internal/server/server_test.go:513–539  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func TestInfer_InvalidJSON400(t *testing.T) {
514 srv := New(testConfig(100, true))
515 ts := httptest.NewServer(srv.Routes())
516 defer ts.Close()
517
518 req, err := http.NewRequest(http.MethodPost, ts.URL+"/infer", bytes.NewBufferString("{"))
519 if err != nil {
520 t.Fatalf("build request: %v", err)
521 }
522 req.Header.Set("Content-Type", "application/json")
523
524 resp, err := http.DefaultClient.Do(req)
525 if err != nil {
526 t.Fatalf("do request: %v", err)
527 }
528 defer resp.Body.Close()
529
530 raw, err := io.ReadAll(resp.Body)
531 if err != nil {
532 t.Fatalf("read body: %v", err)
533 }
534
535 if resp.StatusCode != http.StatusBadRequest {
536 t.Fatalf("expected 400, got %d", resp.StatusCode)
537 }
538 assertStructuredError(t, raw, errCodeInvalidRequest)
539}
540
541func TestInfer_MethodNotAllowed405(t *testing.T) {
542 srv := New(testConfig(100, true))

Callers

nothing calls this directly

Calls 5

assertStructuredErrorFunction · 0.85
RoutesMethod · 0.80
NewFunction · 0.70
testConfigFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected