@@ -25,6 +25,23 @@ import (
2525 "github.com/prometheus/common/model"
2626)
2727
28+ func TestNewTextParser (t * testing.T ) {
29+ p := NewTextParser (model .UTF8Validation )
30+ if p .scheme != model .UTF8Validation {
31+ t .Errorf ("expected NewTextParser to return a TextParser with scheme %s - got %s" , model .UTF8Validation , p .scheme )
32+ }
33+
34+ p = NewTextParser (model .LegacyValidation )
35+ if p .scheme != model .LegacyValidation {
36+ t .Errorf ("expected NewTextParser to return a TextParser with scheme %s - got %s" , model .LegacyValidation , p .scheme )
37+ }
38+
39+ p = NewTextParser (model .UnsetValidation )
40+ if p .scheme != model .UnsetValidation {
41+ t .Errorf ("expected NewTextParser to return a TextParser with scheme %s - got %s" , model .UnsetValidation , p .scheme )
42+ }
43+ }
44+
2845func testTextParse (t testing.TB ) {
2946 scenarios := []struct {
3047 in string
@@ -1001,7 +1018,7 @@ func BenchmarkParseError(b *testing.B) {
10011018
10021019func TestTextParserStartOfLine (t * testing.T ) {
10031020 t .Run ("EOF" , func (t * testing.T ) {
1004- p := TextParser {}
1021+ p := NewTextParser ( model . UTF8Validation )
10051022 in := strings .NewReader ("" )
10061023 p .reset (in )
10071024 fn := p .startOfLine ()
@@ -1014,7 +1031,7 @@ func TestTextParserStartOfLine(t *testing.T) {
10141031 })
10151032
10161033 t .Run ("OtherError" , func (t * testing.T ) {
1017- p := TextParser {}
1034+ p := NewTextParser ( model . UTF8Validation )
10181035 in := & errReader {err : errors .New ("unexpected error" )}
10191036 p .reset (in )
10201037 fn := p .startOfLine ()
0 commit comments