Enhance Unit Tests for Annotations

Adds unit tests for a variety of different annotations.
This commit is contained in:
Fernando Diaz 2019-02-03 19:53:01 -06:00
parent 5c4854b537
commit 1da2900b9b
11 changed files with 544 additions and 45 deletions

View file

@ -17,6 +17,8 @@ limitations under the License.
package ratelimit
import (
"reflect"
"sort"
"testing"
api "k8s.io/api/core/v1"
@ -83,7 +85,24 @@ func TestWithoutAnnotations(t *testing.T) {
}
}
func TestBadRateLimiting(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()
data := map[string]string{}