@@ -25,6 +25,23 @@ import (
25
25
"github.com/prometheus/common/model"
26
26
)
27
27
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
+
28
45
func testTextParse (t testing.TB ) {
29
46
scenarios := []struct {
30
47
in string
@@ -1001,7 +1018,7 @@ func BenchmarkParseError(b *testing.B) {
1001
1018
1002
1019
func TestTextParserStartOfLine (t * testing.T ) {
1003
1020
t .Run ("EOF" , func (t * testing.T ) {
1004
- p := TextParser {}
1021
+ p := NewTextParser ( model . UTF8Validation )
1005
1022
in := strings .NewReader ("" )
1006
1023
p .reset (in )
1007
1024
fn := p .startOfLine ()
@@ -1014,7 +1031,7 @@ func TestTextParserStartOfLine(t *testing.T) {
1014
1031
})
1015
1032
1016
1033
t .Run ("OtherError" , func (t * testing.T ) {
1017
- p := TextParser {}
1034
+ p := NewTextParser ( model . UTF8Validation )
1018
1035
in := & errReader {err : errors .New ("unexpected error" )}
1019
1036
p .reset (in )
1020
1037
fn := p .startOfLine ()
0 commit comments