MCPcopy Create free account
hub / github.com/bracesdev/errtrace / TestWrap_Line

Function TestWrap_Line

errtrace_line_test.go:21–183  ·  view source on GitHub ↗

Note: The following tests verify the line, and assume that the test names are unique, and that they are the only tests in this file.

(t *testing.T)

Source from the content-addressed store, hash-verified

19// Note: The following tests verify the line, and assume that the
20// test names are unique, and that they are the only tests in this file.
21func TestWrap_Line(t *testing.T) {
22 failed := errors.New("failed")
23
24 tests := []struct {
25 name string
26 f func() error
27 }{
28 {
29 name: "return Wrap", // @group
30 f: func() error {
31 return errtrace.Wrap(failed) // @trace
32 },
33 },
34 {
35 name: "Wrap to intermediate and return", // @group
36 f: func() (retErr error) {
37 wrapped := errtrace.Wrap(failed) // @trace
38 return wrapped
39 },
40 },
41 {
42 name: "Decorate error after Wrap", // @group
43 f: func() (retErr error) {
44 wrapped := errtrace.Wrap(failed) // @trace
45 return fmt.Errorf("got err: %w", wrapped)
46 },
47 },
48 {
49 name: "defer updates errTrace", // @group
50 f: func() (retErr error) {
51 defer func() {
52 retErr = errtrace.Wrap(retErr) // @trace
53 }()
54
55 return failed
56 },
57 },
58
59 // Test error creation helpers.
60 {
61 name: "New", // @group
62 f: func() (retErr error) {
63 return errtrace.New("test") // @trace
64 },
65 },
66 {
67 name: "Errorf with no error args", // @group
68 f: func() (retErr error) {
69 return errtrace.Errorf("test %v", 1) // @trace
70 },
71 },
72 {
73 name: "Errorf with wrapped error arg", // @group
74 f: func() (retErr error) {
75 err := errtrace.New("test1") // @trace
76 return errtrace.Errorf("test2: %w", err) // @trace
77 },
78 },

Callers

nothing calls this directly

Calls 15

WrapFunction · 0.92
NewFunction · 0.92
ErrorfFunction · 0.92
Wrap2Function · 0.92
Wrap3Function · 0.92
Wrap4Function · 0.92
Wrap5Function · 0.92
Wrap6Function · 0.92
FormatStringFunction · 0.92
returnErr2Function · 0.85
returnErr3Function · 0.85
returnErr4Function · 0.85

Tested by

no test coverage detected