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

Function TestTextParserStartOfLine

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

Source from the content-addressed store, hash-verified

669}
670
671func TestTextParserStartOfLine(t *testing.T) {
672 t.Run("EOF", func(t *testing.T) {
673 p := TextParser{}
674 in := strings.NewReader("")
675 p.reset(in)
676 fn := p.startOfLine()
677 if fn != nil {
678 t.Errorf("Unexpected non-nil function: %v", fn)
679 }
680 if p.err != nil {
681 t.Errorf("Unexpected error: %v", p.err)
682 }
683 })
684
685 t.Run("OtherError", func(t *testing.T) {
686 p := TextParser{}
687 in := &errReader{err: errors.New("unexpected error")}
688 p.reset(in)
689 fn := p.startOfLine()
690 if fn != nil {
691 t.Errorf("Unexpected non-nil function: %v", fn)
692 }
693 if p.err != nil && !errors.Is(p.err, in.err) {
694 t.Errorf("Unexpected error: %v, expected %v", p.err, in.err)
695 }
696 })
697}
698
699type errReader struct {
700 err error

Callers

nothing calls this directly

Calls 2

resetMethod · 0.95
startOfLineMethod · 0.95

Tested by

no test coverage detected