MCPcopy Create free account
hub / github.com/prometheus/common / TestTextParserStartOfLine

Function TestTextParserStartOfLine

expfmt/text_parse_test.go:1387–1413  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1385}
1386
1387func TestTextParserStartOfLine(t *testing.T) {
1388 t.Run("EOF", func(t *testing.T) {
1389 p := NewTextParser(model.UTF8Validation)
1390 in := strings.NewReader("")
1391 p.reset(in)
1392 fn := p.startOfLine()
1393 if fn != nil {
1394 t.Errorf("Unexpected non-nil function: %v", fn)
1395 }
1396 if p.err != nil {
1397 t.Errorf("Unexpected error: %v", p.err)
1398 }
1399 })
1400
1401 t.Run("OtherError", func(t *testing.T) {
1402 p := NewTextParser(model.UTF8Validation)
1403 in := &errReader{err: errors.New("unexpected error")}
1404 p.reset(in)
1405 fn := p.startOfLine()
1406 if fn != nil {
1407 t.Errorf("Unexpected non-nil function: %v", fn)
1408 }
1409 if p.err != nil && !errors.Is(p.err, in.err) {
1410 t.Errorf("Unexpected error: %v, expected %v", p.err, in.err)
1411 }
1412 })
1413}
1414
1415type errReader struct {
1416 err error

Callers

nothing calls this directly

Calls 3

resetMethod · 0.95
startOfLineMethod · 0.95
NewTextParserFunction · 0.85

Tested by

no test coverage detected