MCPcopy Index your code
hub / github.com/cockroachdb/errors / TestFormat

Function TestFormat

errutil/message_test.go:31–202  ·  view source on GitHub ↗

TestFormat checks edge cases of the utilities in this package. More tests are exercised in the "fmttests" package.

(t *testing.T)

Source from the content-addressed store, hash-verified

29// TestFormat checks edge cases of the utilities in this package.
30// More tests are exercised in the "fmttests" package.
31func TestFormat(t *testing.T) {
32 tt := testutils.T{t}
33
34 testCases := []struct {
35 name string
36 err error
37 expFmtSimple string
38 expFmtVerbose string
39 }{
40 {"newf-empty",
41 errutil.Newf(emptyString),
42 ``, `
43
44(1) attached stack trace
45 -- stack trace:
46 | github.com/cockroachdb/errors/errutil_test.TestFormat
47 | <tab><path>
48 | testing.tRunner
49 | <tab><path>
50 | runtime.goexit
51 | <tab><path>
52Wraps: (2)
53Error types: (1) *withstack.withStack (2) *errutil.leafError`,
54 },
55
56 {"newf-empty-arg",
57 errutil.Newf(emptyString, 123),
58 `%!(EXTRA int=123)`, `
59%!(EXTRA int=123)
60(1) attached stack trace
61 -- stack trace:
62 | github.com/cockroachdb/errors/errutil_test.TestFormat
63 | <tab><path>
64 | testing.tRunner
65 | <tab><path>
66 | runtime.goexit
67 | <tab><path>
68Wraps: (2) %!(EXTRA int=123)
69Error types: (1) *withstack.withStack (2) *errutil.leafError`,
70 },
71
72 {"wrapf-empty",
73 errutil.Wrapf(goErr.New("woo"), emptyString),
74 `woo`, `
75woo
76(1) attached stack trace
77 -- stack trace:
78 | github.com/cockroachdb/errors/errutil_test.TestFormat
79 | <tab><path>
80 | testing.tRunner
81 | <tab><path>
82 | runtime.goexit
83 | <tab><path>
84Wraps: (2) woo
85Error types: (1) *withstack.withStack (2) *errors.errorString`,
86 },
87
88 {"wrapf-empty-arg",

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
CheckStringEqualMethod · 0.95
NewfFunction · 0.92
WrapfFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…