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

Function TestChat402

internal/llm/llm_test.go:494–506  ·  view source on GitHub ↗

TestChat402: budget exhaustion surfaces as a typed error with the snapshot reporting zero remaining, so the UI paints the depleted state immediately.

(t *testing.T)

Source from the content-addressed store, hash-verified

492// TestChat402: budget exhaustion surfaces as a typed error with the snapshot
493// reporting zero remaining, so the UI paints the depleted state immediately.
494func TestChat402(t *testing.T) {
495 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
496 w.WriteHeader(http.StatusPaymentRequired)
497 }))
498 defer srv.Close()
499 evs := collect(New(srv.URL, "m", "k").Chat(context.Background(), nil, nil))
500 if len(evs) != 1 || !errors.Is(evs[0].Err, cloud.ErrBudgetExhausted) {
501 t.Fatalf("want ErrBudgetExhausted, got %+v", evs)
502 }
503 if !evs[0].Budget.Set || evs[0].Budget.Remaining != 0 {
504 t.Fatalf("budget snapshot should report zero remaining: %+v", evs[0].Budget)
505 }
506}
507
508// TestChatUnreachable: transport failure surfaces as ErrUnreachable. Retries
509// off: this test pins the terminal error surface, not the retry path.

Callers

nothing calls this directly

Calls 3

collectFunction · 0.85
ChatMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected