MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestRedactErrorf

Function TestRedactErrorf

base/redactable_error_test.go:17–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestRedactErrorf(t *testing.T) {
18 tests := []struct {
19 name,
20 expectedString,
21 expectedRedact,
22 fmt string
23 args []interface{}
24 }{
25 {
26 name: "%s",
27 expectedString: "Couldn't get user \"Bob\": Not Found",
28 expectedRedact: "Couldn't get user \"<ud>Bob</ud>\": Not Found",
29 fmt: "Couldn't get user %q: %s",
30 args: []interface{}{UD("Bob"), ErrNotFound},
31 },
32 {
33 name: "%w",
34 expectedString: "Couldn't get user \"Bob\": Not Found",
35 expectedRedact: "Couldn't get user \"<ud>Bob</ud>\": Not Found",
36 fmt: "Couldn't get user %q: %w",
37 args: []interface{}{UD("Bob"), ErrNotFound},
38 },
39 }
40 for _, test := range tests {
41 t.Run(test.name, func(t *testing.T) {
42 err := RedactErrorf(test.fmt, test.args...)
43 assert.Equal(t, test.expectedString, err.String())
44 assert.Equal(t, test.expectedRedact, err.Redact())
45 })
46 }
47}
48
49func BenchmarkRedactErrorf(b *testing.B) {
50 fmt := "Couldn't get user %q: "

Callers

nothing calls this directly

Calls 6

RedactErrorfFunction · 0.85
UDFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
RedactMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected