-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaspell_test.go
More file actions
44 lines (38 loc) · 1014 Bytes
/
aspell_test.go
File metadata and controls
44 lines (38 loc) · 1014 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
44
package main
import (
"bufio"
"log"
"os"
"strings"
"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)
aspellCheck, 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)
var readme strings.Builder
for scanner.Scan() {
readme.WriteString(scanner.Text() + "\n")
}
if err := scanner.Err(); err != nil {
t.Errorf("could not read "+filename+" file: %v", err)
}
err = aspellCheck.Check([]string{"subject"}, []string{"body"}, []map[string]string{
{filename: readme.String()},
}, &junit.JunitSuiteDummy{}, nil)
if err != nil {
t.Errorf("checkWithAspell() error = %v", err)
}
}