MCPcopy
hub / github.com/pkg/errors / TestUnwrap

Function TestUnwrap

go113_test.go:139–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestUnwrap(t *testing.T) {
140 err := New("test")
141
142 type args struct {
143 err error
144 }
145 tests := []struct {
146 name string
147 args args
148 want error
149 }{
150 {
151 name: "with stack",
152 args: args{err: WithStack(err)},
153 want: err,
154 },
155 {
156 name: "with message",
157 args: args{err: WithMessage(err, "test")},
158 want: err,
159 },
160 {
161 name: "with message format",
162 args: args{err: WithMessagef(err, "%s", "test")},
163 want: err,
164 },
165 {
166 name: "std errors compatibility",
167 args: args{err: fmt.Errorf("wrap: %w", err)},
168 want: err,
169 },
170 }
171 for _, tt := range tests {
172 t.Run(tt.name, func(t *testing.T) {
173 if err := Unwrap(tt.args.err); !reflect.DeepEqual(err, tt.want) {
174 t.Errorf("Unwrap() error = %v, want %v", err, tt.want)
175 }
176 })
177 }
178}

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
WithStackFunction · 0.85
WithMessageFunction · 0.85
WithMessagefFunction · 0.85
UnwrapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…