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

Function TestClassifyError

coderd/x/chatd/chatdebug/service_test.go:830–863  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

828}
829
830func TestClassifyError(t *testing.T) {
831 t.Parallel()
832
833 tests := []struct {
834 name string
835 err error
836 want chatdebug.Status
837 }{
838 {"nil", nil, chatdebug.StatusCompleted},
839 {"context.Canceled", context.Canceled, chatdebug.StatusInterrupted},
840 // Wrapped context.Canceled must still classify as interrupted so
841 // callers that decorate cancellation errors do not flip to
842 // StatusError.
843 {
844 "wrapped context.Canceled",
845 xerrors.Errorf("canceled mid-stream: %w", context.Canceled),
846 chatdebug.StatusInterrupted,
847 },
848 {"generic error", xerrors.New("boom"), chatdebug.StatusError},
849 // context.DeadlineExceeded is not context.Canceled and is not
850 // special-cased by ClassifyError, so it must fall through to
851 // StatusError. This pins the priority ordering in the switch.
852 {
853 "context.DeadlineExceeded",
854 context.DeadlineExceeded, chatdebug.StatusError,
855 },
856 }
857 for _, tt := range tests {
858 t.Run(tt.name, func(t *testing.T) {
859 t.Parallel()
860 require.Equal(t, tt.want, chatdebug.ClassifyError(tt.err))
861 })
862 }
863}
864
865func TestService_FinalizeRun_FallsBackToSeedSummary(t *testing.T) {
866 t.Parallel()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected