mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Add unit test
This commit is contained in:
parent
30a261d97c
commit
b56d8dd513
@ -6531,14 +6531,14 @@ func TestValidateRestartPolicy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateDNSPolicy(t *testing.T) {
|
||||
successCases := []core.DNSPolicy{core.DNSClusterFirst, core.DNSDefault, core.DNSPolicy(core.DNSClusterFirst), core.DNSNone}
|
||||
successCases := []core.DNSPolicy{core.DNSClusterFirst, core.DNSDefault, core.DNSClusterFirstWithHostNet, core.DNSNone}
|
||||
for _, policy := range successCases {
|
||||
if errs := validateDNSPolicy(&policy, field.NewPath("field")); len(errs) != 0 {
|
||||
t.Errorf("expected success: %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := []core.DNSPolicy{core.DNSPolicy("invalid")}
|
||||
errorCases := []core.DNSPolicy{core.DNSPolicy("invalid"), core.DNSPolicy("")}
|
||||
for _, policy := range errorCases {
|
||||
if errs := validateDNSPolicy(&policy, field.NewPath("field")); len(errs) == 0 {
|
||||
t.Errorf("expected failure for %v", policy)
|
||||
|
Loading…
Reference in New Issue
Block a user