github.com/errata-ai/vale/v3@v3.4.2/internal/check/manager_test.go (about) 1 package check 2 3 import ( 4 "testing" 5 ) 6 7 /*var checktests = []struct { 8 check string 9 msg string 10 }{ 11 {"NoExtends.yml", "YAML.NoExtends: missing extension point!"}, 12 {"NoMsg.yml", "YAML.NoMsg: missing message!"}, 13 } 14 15 func TestAddCheck(t *testing.T) { 16 cfg, err := config.New() 17 if err != nil { 18 panic(err) 19 } 20 21 mgr := Manager{ 22 AllChecks: make(map[string]Check), 23 Config: cfg, 24 Scopes: make(map[string]struct{})} 25 26 for _, tt := range checktests { 27 path, err := filepath.Abs(filepath.Join("../fixtures/YAML", tt.check)) 28 if err != nil { 29 panic(err) 30 } 31 s := mgr.loadCheck(tt.check, path) 32 if s.Error() != tt.msg { 33 t.Errorf("%q != %q", s.Error(), tt.msg) 34 } 35 } 36 }*/ 37 38 var msgtests = []struct { 39 in string 40 args []string 41 out string 42 }{ 43 {"Avoid using '%s'", []string{"foo", "bar"}, "Avoid using 'foo'"}, 44 {"Avoid using 'foo'", []string{"foo", "bar"}, "Avoid using 'foo'"}, 45 {"Use '%s', not '%s'", []string{"foo", "bar"}, "Use 'foo', not 'bar'"}, 46 } 47 48 func TestFormatMessage(t *testing.T) { 49 for _, tt := range msgtests { 50 s, _ := formatMessages(tt.in, tt.in, tt.args...) 51 if s != tt.out { 52 t.Errorf("(%q, %v) => %q != %q", tt.in, tt.args, s, tt.out) 53 } 54 } 55 }