MCPcopy Create free account
hub / github.com/cockroachdb/errors / TestFormat

Function TestFormat

safedetails/safedetails_test.go:70–291  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestFormat(t *testing.T) {
71 tt := testutils.T{t}
72
73 baseErr := errors.New("woo")
74 const woo = `woo`
75 const waawoo = `waa: woo`
76 // rm is what's left over after redaction.
77 rm := string(redact.RedactableBytes(redact.RedactedMarker()).StripMarkers())
78
79 testCases := []struct {
80 name string
81 err error
82 expFmtSimple string
83 expFmtVerbose string
84 details string
85 }{
86 {"safe onearg",
87 safedetails.WithSafeDetails(baseErr, "a"),
88 woo, `
89woo
90(1) a
91Wraps: (2) woo
92Error types: (1) *safedetails.withSafeDetails (2) *errors.errorString`,
93 // Payload
94 `payload 0
95 (0) a
96payload 1
97 (empty)
98`},
99
100 {"safe empty",
101 safedetails.WithSafeDetails(baseErr, ""),
102 woo, `
103woo
104(1) woo
105Error types: (1) *errors.errorString`,
106 // Payload
107 `payload 0
108 (empty)
109`},
110
111 {"safe nofmt+onearg",
112 safedetails.WithSafeDetails(baseErr, "%v", 123),
113 woo, `
114woo
115(1) ` + rm + `
116Wraps: (2) woo
117Error types: (1) *safedetails.withSafeDetails (2) *errors.errorString`,
118 // Payload
119 `payload 0
120 (0) ` + rm + `
121payload 1
122 (empty)
123`},
124
125 {"safe err",
126 safedetails.WithSafeDetails(baseErr, "prefix: %v",
127 &os.PathError{

Callers

nothing calls this directly

Calls 7

RunMethod · 0.95
CheckStringEqualMethod · 0.95
WithSafeDetailsFunction · 0.92
SafeFunction · 0.92
FormattableFunction · 0.92
GetAllSafeDetailsFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…