MCPcopy
hub / github.com/sirupsen/logrus / TestEscaping_Interface

Function TestEscaping_Interface

text_formatter_test.go:119–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117}
118
119func TestEscaping_Interface(t *testing.T) {
120 tf := &TextFormatter{DisableColors: true}
121
122 ts := time.Now()
123
124 testCases := []struct {
125 value interface{}
126 expected string
127 }{
128 {ts, fmt.Sprintf("\"%s\"", ts.String())},
129 {errors.New("error: something went wrong"), "\"error: something went wrong\""},
130 }
131
132 for _, tc := range testCases {
133 b, _ := tf.Format(WithField("test", tc.value))
134 if !bytes.Contains(b, []byte(tc.expected)) {
135 t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
136 }
137 }
138}
139
140func TestTimestampFormat(t *testing.T) {
141 checkTimeStr := func(format string) {

Callers

nothing calls this directly

Calls 4

FormatMethod · 0.95
WithFieldFunction · 0.85
ErrorfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected