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

Function TestFormatUnimp

issuelink/unimplemented_test.go:63–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestFormatUnimp(t *testing.T) {
64 tt := testutils.T{t}
65
66 link := issuelink.IssueLink{IssueURL: "http://mysite"}
67 const woo = `woo`
68 const waawoo = `waa: woo`
69 testCases := []struct {
70 name string
71 err error
72 expFmtSimple string
73 expFmtVerbose string
74 }{
75 {"unimp",
76 issuelink.UnimplementedError(link, "woo"),
77 woo, `
78woo
79(1) woo
80 | unimplemented
81 | issue: http://mysite
82Error types: (1) *issuelink.unimplementedError`},
83 {"unimp-details",
84 issuelink.UnimplementedError(issuelink.IssueLink{IssueURL: "http://mysite", Detail: "see more"}, "woo"),
85 woo, `
86woo
87(1) woo
88 | unimplemented
89 | issue: http://mysite
90 | detail: see more
91Error types: (1) *issuelink.unimplementedError`},
92
93 {"wrapper + unimp",
94 &werrFmt{issuelink.UnimplementedError(link, "woo"), "waa"},
95 waawoo, `
96waa: woo
97(1) waa
98 | -- this is waa's
99 | multi-line payload
100Wraps: (2) woo
101 | unimplemented
102 | issue: http://mysite
103Error types: (1) *issuelink_test.werrFmt (2) *issuelink.unimplementedError`},
104 }
105
106 for _, test := range testCases {
107 tt.Run(test.name, func(tt testutils.T) {
108 err := test.err
109
110 // %s is simple formatting
111 tt.CheckStringEqual(fmt.Sprintf("%s", err), test.expFmtSimple)
112
113 // %v is simple formatting too, for compatibility with the past.
114 tt.CheckStringEqual(fmt.Sprintf("%v", err), test.expFmtSimple)
115
116 // %q is always like %s but quotes the result.
117 ref := fmt.Sprintf("%q", test.expFmtSimple)
118 tt.CheckStringEqual(fmt.Sprintf("%q", err), ref)
119
120 // %+v is the verbose mode.

Callers

nothing calls this directly

Calls 3

RunMethod · 0.95
CheckStringEqualMethod · 0.95
UnimplementedErrorFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…