MCPcopy Create free account
hub / github.com/diillson/chatcli / TestCallExtraction_FallbackProviderServes

Function TestCallExtraction_FallbackProviderServes

cli/memory_pending_test.go:55–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestCallExtraction_FallbackProviderServes(t *testing.T) {
56 t.Setenv("CHATCLI_MEMORY_FALLBACK_PROVIDERS", "OPENAI")
57 primary := &scriptedClient{name: "claude", failN: 99}
58 fallback := &scriptedClient{name: "openai", response: "NOTHING_NEW"}
59
60 mw := newResilienceWorker(t, primary)
61 mw.lookupFallback = func(provider string) (client.LLMClient, error) {
62 if provider != "OPENAI" {
63 return nil, fmt.Errorf("unexpected provider %s", provider)
64 }
65 return fallback, nil
66 }
67
68 resp, err := mw.callExtraction(context.Background(), "prompt", nil)
69 if err != nil {
70 t.Fatalf("callExtraction: %v", err)
71 }
72 if resp != "NOTHING_NEW" {
73 t.Fatalf("resp = %q, want fallback answer", resp)
74 }
75 if primary.calls.Load() == 0 || fallback.calls.Load() == 0 {
76 t.Fatal("both primary and fallback must have been tried, in order")
77 }
78}
79
80func TestCallExtraction_AllProvidersFail(t *testing.T) {
81 t.Setenv("CHATCLI_MEMORY_FALLBACK_PROVIDERS", "")

Callers

nothing calls this directly

Calls 4

newResilienceWorkerFunction · 0.85
ErrorfMethod · 0.80
callExtractionMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected