add access log filter for retry attempts
This commit is contained in:
parent
5792a19b97
commit
c762b9bb2e
6 changed files with 116 additions and 28 deletions
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue