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

Function TestNew

errors_test.go:11–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNew(t *testing.T) {
12 tests := []struct {
13 err string
14 want error
15 }{
16 {"", fmt.Errorf("")},
17 {"foo", fmt.Errorf("foo")},
18 {"foo", New("foo")},
19 {"string with format specifiers: %v", errors.New("string with format specifiers: %v")},
20 }
21
22 for _, tt := range tests {
23 got := New(tt.err)
24 if got.Error() != tt.want.Error() {
25 t.Errorf("New.Error(): got: %q, want %q", got, tt.want)
26 }
27 }
28}
29
30func TestWrapNil(t *testing.T) {
31 got := Wrap(nil, "no error")

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…