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

Function TestFormatSingleLineOutput

errbase/format_error_internal_test.go:331–354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

329}
330
331func TestFormatSingleLineOutput(t *testing.T) {
332 b := func(s string) []byte { return []byte(s) }
333 testCases := []struct {
334 entries []formatEntry
335 exp string
336 }{
337 {[]formatEntry{{}}, ``},
338 {[]formatEntry{{head: b(`a`)}}, `a`},
339 {[]formatEntry{{head: b(`a`)}, {head: b(`b`)}, {head: b(`c`)}}, `c: b: a`},
340 {[]formatEntry{{}, {head: b(`b`)}}, `b`},
341 {[]formatEntry{{head: b(`a`)}, {}}, `a`},
342 {[]formatEntry{{head: b(`a`)}, {}, {head: b(`c`)}}, `c: a`},
343 {[]formatEntry{{head: b(`a`), elideShort: true}, {head: b(`b`)}}, `b`},
344 {[]formatEntry{{head: b("abc\ndef")}, {head: b("ghi\nklm")}}, "ghi\nklm: abc\ndef"},
345 }
346
347 for _, tc := range testCases {
348 s := state{entries: tc.entries}
349 s.formatSingleLineOutput()
350 if s.finalBuf.String() != tc.exp {
351 t.Errorf("%s: expected %q, got %q", tc.entries, tc.exp, s.finalBuf.String())
352 }
353 }
354}
355
356func TestPrintEntryRedactable(t *testing.T) {
357 sm := string(redact.StartMarker())

Callers

nothing calls this directly

Calls 2

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…