@@ -59,7 +59,35 @@ func TestNdots(t *testing.T) {
59
59
t .Errorf ("Ndots not properly parsed: (Expected: %d / Was: %d)" , ndotsVariants [data ], cc .Ndots )
60
60
}
61
61
}
62
+ }
63
+
64
+ func TestClientConfigFromReaderAttempts (t * testing.T ) {
65
+ testCases := []struct {
66
+ data string
67
+ expected int
68
+ }{
69
+ {data : "options attempts:0" , expected : 1 },
70
+ {data : "options attempts:1" , expected : 1 },
71
+ {data : "options attempts:15" , expected : 15 },
72
+ {data : "options attempts:16" , expected : 16 },
73
+ {data : "options attempts:-1" , expected : 1 },
74
+ {data : "options attempt:" , expected : 2 },
75
+ }
62
76
77
+ for _ , test := range testCases {
78
+ test := test
79
+ t .Run (strings .Replace (test .data , ":" , " " , - 1 ), func (t * testing.T ) {
80
+ t .Parallel ()
81
+
82
+ cc , err := ClientConfigFromReader (strings .NewReader (test .data ))
83
+ if err != nil {
84
+ t .Errorf ("error parsing resolv.conf: %v" , err )
85
+ }
86
+ if cc .Attempts != test .expected {
87
+ t .Errorf ("A attempts not properly parsed: (Expected: %d / Was: %d)" , test .expected , cc .Attempts )
88
+ }
89
+ })
90
+ }
63
91
}
64
92
65
93
func TestReadFromFile (t * testing.T ) {
0 commit comments