MCPcopy Create free account
hub / github.com/vale-cli/vale / TestComments

Function TestComments

internal/lint/code/comments_test.go:14–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12var binDir = "../../../bin"
13
14func TestComments(t *testing.T) {
15 var cleaned []fs.DirEntry
16
17 cases, err := os.ReadDir(testDir + "/in")
18 if err != nil {
19 t.Error(err)
20 }
21
22 for _, f := range cases {
23 if f.Name() == ".DS_Store" {
24 continue
25 }
26 cleaned = append(cleaned, f)
27 }
28
29 for i, f := range cleaned {
30 b, err1 := os.ReadFile(fmt.Sprintf("%s/in/%s", testDir, f.Name()))
31 if err1 != nil {
32 t.Error(err1)
33 }
34
35 lang, err2 := GetLanguageFromExt(filepath.Ext(f.Name()))
36 if err2 != nil {
37 t.Error(err2)
38 }
39
40 comments, err3 := GetComments(b, lang)
41 if err3 != nil {
42 t.Error(err3)
43 }
44
45 b2, err4 := os.ReadFile(fmt.Sprintf("%s/out/%d.json", testDir, i))
46 if err4 != nil {
47 t.Error(err4)
48 }
49
50 markup := toJSON(comments)
51 if markup != string(b2) {
52 bin := filepath.Join(binDir, fmt.Sprintf("%d.json", i))
53 _ = os.WriteFile(bin, []byte(markup), 0600)
54 t.Errorf("%s", markup)
55 }
56 }
57}

Callers

nothing calls this directly

Calls 3

GetLanguageFromExtFunction · 0.85
GetCommentsFunction · 0.85
toJSONFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…