MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestNonNilMultiError_Error

Function TestNonNilMultiError_Error

pkg/util/multierror/multierror_test.go:95–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestNonNilMultiError_Error(t *testing.T) {
96 tests := []struct {
97 name string
98 errs []error
99 expected string
100 }{
101 {
102 name: "single error has no prefix",
103 errs: []error{errors.New("something failed")},
104 expected: "something failed",
105 },
106 {
107 name: "multiple errors have count prefix",
108 errs: []error{errors.New("err1"), errors.New("err2")},
109 expected: "2 errors: err1; err2",
110 },
111 {
112 name: "three errors",
113 errs: []error{errors.New("a"), errors.New("b"), errors.New("c")},
114 expected: "3 errors: a; b; c",
115 },
116 }
117
118 for _, tt := range tests {
119 t.Run(tt.name, func(t *testing.T) {
120 me := New(tt.errs...)
121 err := me.Err()
122 require.Error(t, err)
123 assert.Equal(t, tt.expected, err.Error())
124 })
125 }
126}
127
128func TestNew(t *testing.T) {
129 tests := []struct {

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
RunMethod · 0.65
ErrMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected