kubeadm: tests for apis/kubeadn/validation pkg

pull/6/head
Derek McQuay 2017-02-06 14:40:52 -08:00 committed by Lucas Käldström
parent 407722b378
commit 8cf23139e6
No known key found for this signature in database
GPG Key ID: 600FEFBBD0D40D21
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
package validation
import (
"testing"
"k8s.io/apimachinery/pkg/util/validation/field"
)
func TestValidateServiceSubnet(t *testing.T) {
var tests = []struct {
s string
f *field.Path
expected bool
}{
{"", nil, false},
{"this is not a cidr", nil, false}, // not a CIDR
{"10.0.0.1", nil, false}, // not a CIDR
{"192.0.2.0/1", nil, false}, // CIDR too smal
{"192.0.2.0/24", nil, true},
}
for _, rt := range tests {
actual := ValidateServiceSubnet(rt.s, rt.f)
if (len(actual) == 0) != rt.expected {
t.Errorf(
"failed ValidateServiceSubnet:\n\texpected: %t\n\t actual: %t",
rt.expected,
(len(actual) == 0),
)
}
}
}