MCPcopy Index your code
hub / github.com/coder/coder / TestClassify

Function TestClassify

coderd/x/chatd/chaterror/classify_test.go:21–309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestClassify(t *testing.T) {
22 t.Parallel()
23
24 tests := []struct {
25 name string
26 err error
27 want chaterror.ClassifiedError
28 }{
29 {
30 name: "AmbiguousOverloadKeepsProviderUnknown",
31 err: xerrors.New("status 529 from upstream"),
32 want: chaterror.ClassifiedError{
33 Message: "The AI provider is temporarily overloaded.",
34 Kind: codersdk.ChatErrorKindOverloaded,
35 Provider: "",
36 Retryable: true,
37 StatusCode: 529,
38 },
39 },
40 {
41 name: "ExplicitAnthropicOverload",
42 err: xerrors.New("anthropic overloaded_error"),
43 want: chaterror.ClassifiedError{
44 Message: "Anthropic is temporarily overloaded.",
45 Kind: codersdk.ChatErrorKindOverloaded,
46 Provider: "anthropic",
47 Retryable: true,
48 StatusCode: 0,
49 },
50 },
51 {
52 name: "AnthropicMissingMessageStop",
53 err: xerrors.Errorf(
54 "anthropic stream closed before message_stop: %w",
55 io.EOF,
56 ),
57 want: chaterror.ClassifiedError{
58 Message: "Anthropic stream closed unexpectedly before the response completed.",
59 Kind: codersdk.ChatErrorKindTimeout,
60 Provider: "anthropic",
61 Retryable: true,
62 StatusCode: 0,
63 },
64 },
65 {
66 name: "OpenAIResponsesMissingTerminalEvent",
67 err: xerrors.Errorf(
68 "openai responses stream closed before terminal event: %w",
69 io.EOF,
70 ),
71 want: chaterror.ClassifiedError{
72 Message: "OpenAI stream closed unexpectedly before the response completed.",
73 Kind: codersdk.ChatErrorKindTimeout,
74 Provider: "openai",
75 Retryable: true,
76 StatusCode: 0,
77 },
78 },

Callers

nothing calls this directly

Calls 5

ClassifyFunction · 0.92
NewMethod · 0.65
RunMethod · 0.65
ErrorfMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected