github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/pkg/inspector/rule/rule_test.go (about) 1 package rule 2 3 import "testing" 4 5 func TestDefaultRules(t *testing.T) { 6 // This will panic if there are errors in the default rule 7 rules := DefaultRules(map[string]string{"kubernetes_yum_version": "1.10.3-0", "kubernetes_deb_version": "1.10.3-00"}) 8 if len(rules) != 75 { 9 t.Errorf("expected to have %d rules, instead got %d", 75, len(rules)) 10 } 11 for _, r := range rules { 12 if errs := r.Validate(); len(errs) != 0 { 13 t.Errorf("invalid default rule was found: %+v. Errors are: %v", r, errs) 14 } 15 } 16 } 17 18 func TestUpgradeRules(t *testing.T) { 19 // This will panic if there are errors in the upgrade rule 20 rules := UpgradeRules(map[string]string{"kubernetes_yum_version": "1.10.3-0", "kubernetes_deb_version": "1.10.3-00"}) 21 if len(rules) != 16 { 22 t.Errorf("expected to have %d rules, instead got %d", 16, len(rules)) 23 } 24 for _, r := range rules { 25 if errs := r.Validate(); len(errs) != 0 { 26 t.Errorf("invalid default rule was found: %+v. Errors are: %v", r, errs) 27 } 28 } 29 }