You've already forked nginx_exporter
mirror of
https://github.com/nginxinc/nginx-prometheus-exporter.git
synced 2025-08-08 05:02:04 +03:00
Fix nginxRetries and timeout accepts a negative value
* Bug introduced in: b499ca793a
This commit is contained in:
@@ -11,7 +11,7 @@ func TestCreateClientWithRetries(t *testing.T) {
|
||||
type args struct {
|
||||
client interface{}
|
||||
err error
|
||||
retries int
|
||||
retries uint
|
||||
retryInterval time.Duration
|
||||
}
|
||||
|
||||
@@ -81,3 +81,43 @@ func TestCreateClientWithRetries(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePositiveDuration(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
testInput string
|
||||
want positiveDuration
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
"ParsePositiveDuration returns a positiveDuration",
|
||||
"15ms",
|
||||
positiveDuration{15 * time.Millisecond},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"ParsePositiveDuration returns error for trying to parse negative value",
|
||||
"-15ms",
|
||||
positiveDuration{},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"ParsePositiveDuration returns error for trying to parse empty string",
|
||||
"",
|
||||
positiveDuration{},
|
||||
true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := parsePositiveDuration(tt.testInput)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parsePositiveDuration() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("parsePositiveDuration() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user