|
1 | 1 | package aspell
|
2 | 2 |
|
3 |
| -import "testing" |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | +) |
4 | 6 |
|
5 | 7 | func Test_checkWithAspell(t *testing.T) {
|
6 | 8 | aspell := Aspell{
|
@@ -31,3 +33,68 @@ func Test_checkWithAspell(t *testing.T) {
|
31 | 33 | })
|
32 | 34 | }
|
33 | 35 | }
|
| 36 | + |
| 37 | +func TestAspell_Check(t *testing.T) { |
| 38 | + type fields struct { |
| 39 | + Mode mode |
| 40 | + MinLength int |
| 41 | + IgnoreFiles []string |
| 42 | + AllowedWords []string |
| 43 | + HelpText string |
| 44 | + } |
| 45 | + type args struct { |
| 46 | + subjects []string |
| 47 | + commitsFull []string |
| 48 | + content []map[string]string |
| 49 | + } |
| 50 | + tests := []struct { |
| 51 | + name string |
| 52 | + fields fields |
| 53 | + args args |
| 54 | + wantErr bool |
| 55 | + }{{ |
| 56 | + "Signed off", |
| 57 | + fields{ |
| 58 | + Mode: modeCommit, |
| 59 | + MinLength: 3, |
| 60 | + IgnoreFiles: []string{"config"}, |
| 61 | + AllowedWords: []string{"config"}, |
| 62 | + HelpText: "test", |
| 63 | + }, |
| 64 | + args{ |
| 65 | + subjects: []string{"BUG/MEDIUM: config: add default location of path to the configuration file"}, |
| 66 | + commitsFull: [] string{ " Signed-off-by: Author: A locatoin <[email protected]>"}, |
| 67 | + content: []map[string]string{{"test": "test"}}, |
| 68 | + }, |
| 69 | + false, |
| 70 | + }, { |
| 71 | + "Signed off", |
| 72 | + fields{ |
| 73 | + Mode: modeCommit, |
| 74 | + MinLength: 3, |
| 75 | + IgnoreFiles: []string{"config"}, |
| 76 | + AllowedWords: []string{"config"}, |
| 77 | + HelpText: "test", |
| 78 | + }, |
| 79 | + args{ |
| 80 | + subjects: []string{"BUG/MEDIUM: config: add default location of path to the configuration file"}, |
| 81 | + commitsFull: [] string{ "mitsake", " Signed-off-by: Author: A locatoin <[email protected]>"}, |
| 82 | + content: []map[string]string{{"test": "test"}}, |
| 83 | + }, |
| 84 | + true, |
| 85 | + }} |
| 86 | + for _, tt := range tests { |
| 87 | + t.Run(tt.name, func(t *testing.T) { |
| 88 | + a := Aspell{ |
| 89 | + Mode: tt.fields.Mode, |
| 90 | + MinLength: tt.fields.MinLength, |
| 91 | + IgnoreFiles: tt.fields.IgnoreFiles, |
| 92 | + AllowedWords: tt.fields.AllowedWords, |
| 93 | + HelpText: tt.fields.HelpText, |
| 94 | + } |
| 95 | + if err := a.Check(tt.args.subjects, tt.args.commitsFull, tt.args.content); (err != nil) != tt.wantErr { |
| 96 | + t.Errorf("Aspell.Check() error = %v, wantErr %v", err, tt.wantErr) |
| 97 | + } |
| 98 | + }) |
| 99 | + } |
| 100 | +} |
0 commit comments