-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaspell_test.go
More file actions
43 lines (37 loc) · 955 Bytes
/
aspell_test.go
File metadata and controls
43 lines (37 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"bufio"
"log"
"os"
"testing"
"github.com/haproxytech/check-commit/v5/aspell"
"github.com/haproxytech/check-commit/v5/junit"
)
func Test_Aspell(t *testing.T) {
log.SetFlags(log.LstdFlags | log.Lshortfile)
aspell, err := aspell.New(".aspell.yml")
if err != nil {
t.Errorf("checkWithAspell() error = %v", err)
}
filename := "README.md"
// filename := "check.go"
readmeFile, err := os.Open(filename)
if err != nil {
t.Errorf("could not open "+filename+" file: %v", err)
}
defer readmeFile.Close()
scanner := bufio.NewScanner(readmeFile)
readme := ""
for scanner.Scan() {
readme += scanner.Text() + "\n"
}
if err := scanner.Err(); err != nil {
t.Errorf("could not read "+filename+" file: %v", err)
}
err = aspell.Check([]string{"subject"}, []string{"body"}, []map[string]string{
{filename: readme},
}, &junit.JunitSuiteDummy{})
if err != nil {
t.Errorf("checkWithAspell() error = %v", err)
}
}