MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestChatOtherHTTPError

Function TestChatOtherHTTPError

internal/llm/llm_test.go:523–541  ·  view source on GitHub ↗

TestChatOtherHTTPError: non-2xx (not 401/402) surfaces as a generic error carrying only the first body line.

(t *testing.T)

Source from the content-addressed store, hash-verified

521}
522
523// TestChatOtherHTTPError: non-2xx (not 401/402) surfaces as a generic error
524// carrying only the first body line. Retries off: this test pins the terminal
525// error surface, not the retry path.
526func TestChatOtherHTTPError(t *testing.T) {
527 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
528 w.WriteHeader(http.StatusInternalServerError)
529 fmt.Fprintln(w, "engine exploded")
530 fmt.Fprintln(w, "see logs")
531 }))
532 defer srv.Close()
533 c := New(srv.URL, "m", "")
534 c.RetryBackoff = nil
535 evs := collect(c.Chat(context.Background(), nil, nil))
536 if len(evs) != 1 || evs[0].Kind != EventError {
537 t.Fatalf("want single error event, got %+v", evs)
538 }
539 if !strings.Contains(evs[0].Err.Error(), "500") ||
540 !strings.Contains(evs[0].Err.Error(), "engine exploded") {
541 t.Fatalf("error should include status and body excerpt: %v", evs[0].Err)
542 }
543 if strings.Contains(evs[0].Err.Error(), "see logs") {
544 t.Fatalf("error should include only first body line: %v", evs[0].Err)

Callers

nothing calls this directly

Calls 4

collectFunction · 0.85
ChatMethod · 0.80
ErrorMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected