generalize cidr parsing and improve lua tests
This commit is contained in:
parent
2254a91866
commit
2cff9fa41d
7 changed files with 68 additions and 70 deletions
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||
package ratelimit
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
api "k8s.io/api/core/v1"
|
||||
|
|
@ -85,23 +83,6 @@ func TestWithoutAnnotations(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParseCIDRs(t *testing.T) {
|
||||
cidr, _ := parseCIDRs("invalid.com")
|
||||
if cidr != nil {
|
||||
t.Errorf("expected %v but got %v", nil, cidr)
|
||||
}
|
||||
|
||||
expected := []string{"192.0.0.1", "192.0.1.0/24"}
|
||||
cidr, err := parseCIDRs("192.0.0.1, 192.0.1.0/24")
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error %v", err)
|
||||
}
|
||||
sort.Strings(cidr)
|
||||
if !reflect.DeepEqual(expected, cidr) {
|
||||
t.Errorf("expected %v but got %v", expected, cidr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRateLimiting(t *testing.T) {
|
||||
ing := buildIngress()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue