MCPcopy Create free account
hub / github.com/docker/docker-agent / TestClassifyModelCallError

Function TestClassifyModelCallError

pkg/rag/strategy/vector_store_test.go:27–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestClassifyModelCallError(t *testing.T) {
28 t.Parallel()
29 tests := []struct {
30 name string
31 err error
32 wantAborted bool
33 }{
34 {name: "nil", err: nil, wantAborted: false},
35 {name: "404 model not found", err: &modelerrors.StatusError{StatusCode: http.StatusNotFound, Err: errors.New("not_found_error: model: claude-sonnet-4-7")}, wantAborted: true},
36 {name: "401 unauthorized", err: &modelerrors.StatusError{StatusCode: http.StatusUnauthorized, Err: errors.New("unauthorized")}, wantAborted: true},
37 {name: "429 rate limited", err: &modelerrors.StatusError{StatusCode: http.StatusTooManyRequests, Err: errors.New("too many requests")}, wantAborted: true},
38 {name: "500 server error", err: &modelerrors.StatusError{StatusCode: http.StatusInternalServerError, Err: errors.New("server error")}, wantAborted: false},
39 {name: "timeout message", err: errors.New("request timeout"), wantAborted: false},
40 {name: "context canceled", err: context.Canceled, wantAborted: false},
41 {name: "context deadline", err: context.DeadlineExceeded, wantAborted: false},
42 {name: "wrapped 404", err: fmt.Errorf("batch 1 failed: %w", &modelerrors.StatusError{StatusCode: http.StatusNotFound, Err: errors.New("no such model")}), wantAborted: true},
43 }
44
45 for _, tt := range tests {
46 t.Run(tt.name, func(t *testing.T) {
47 got := classifyModelCallError(tt.err)
48 assert.Equal(t, tt.wantAborted, isIndexingAborted(got))
49 if tt.err != nil {
50 assert.ErrorIs(t, got, tt.err)
51 }
52 })
53 }
54}
55
56// fakeEmbeddingProvider counts embedding calls and always fails with a fixed error.
57type fakeEmbeddingProvider struct {

Callers

nothing calls this directly

Calls 4

classifyModelCallErrorFunction · 0.85
isIndexingAbortedFunction · 0.85
RunMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected