forked from SW/traefik
add access log filter for retry attempts
This commit is contained in:
committed by
Traefiker Bot
parent
5792a19b97
commit
c762b9bb2e
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -93,3 +94,45 @@ func TestNewHTTPCodeRanges(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPCodeRanges_Contains(t *testing.T) {
|
||||
testCases := []struct {
|
||||
strBlocks []string
|
||||
statusCode int
|
||||
contains bool
|
||||
}{
|
||||
{
|
||||
strBlocks: []string{"200-299"},
|
||||
statusCode: 200,
|
||||
contains: true,
|
||||
},
|
||||
{
|
||||
strBlocks: []string{"200"},
|
||||
statusCode: 200,
|
||||
contains: true,
|
||||
},
|
||||
{
|
||||
strBlocks: []string{"201"},
|
||||
statusCode: 200,
|
||||
contains: false,
|
||||
},
|
||||
{
|
||||
strBlocks: []string{"200-299", "500-599"},
|
||||
statusCode: 400,
|
||||
contains: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
test := test
|
||||
testName := fmt.Sprintf("%q contains %d", test.strBlocks, test.statusCode)
|
||||
t.Run(testName, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
httpCodeRanges, err := NewHTTPCodeRanges(test.strBlocks)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, test.contains, httpCodeRanges.Contains(test.statusCode))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user