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

Function TestTextParserStartOfLine

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

Source from the content-addressed store, hash-verified

1415}
1416
1417func TestTextParserStartOfLine(t *testing.T) {
1418 t.Run("EOF", func(t *testing.T) {
1419 p := NewTextParser(model.UTF8Validation)
1420 in := strings.NewReader("")
1421 p.reset(in)
1422 fn := p.startOfLine()
1423 if fn != nil {
1424 t.Errorf("Unexpected non-nil function: %v", fn)
1425 }
1426 if p.err != nil {
1427 t.Errorf("Unexpected error: %v", p.err)
1428 }
1429 })
1430
1431 t.Run("OtherError", func(t *testing.T) {
1432 p := NewTextParser(model.UTF8Validation)
1433 in := &errReader{err: errors.New("unexpected error")}
1434 p.reset(in)
1435 fn := p.startOfLine()
1436 if fn != nil {
1437 t.Errorf("Unexpected non-nil function: %v", fn)
1438 }
1439 if p.err != nil && !errors.Is(p.err, in.err) {
1440 t.Errorf("Unexpected error: %v, expected %v", p.err, in.err)
1441 }
1442 })
1443}
1444
1445type errReader struct {
1446 err error

Callers

nothing calls this directly

Calls 3

resetMethod · 0.95
startOfLineMethod · 0.95
NewTextParserFunction · 0.85

Tested by

no test coverage detected