1
1
package processors
2
2
3
3
import (
4
- "path"
5
4
"path/filepath"
6
5
"testing"
7
6
@@ -13,7 +12,7 @@ import (
13
12
)
14
13
15
14
func TestExclusionRules_Process_multiple (t * testing.T ) {
16
- files := fsutils .NewFiles ( fsutils . NewLineCache (fsutils .NewFileCache ()), "" )
15
+ lines := fsutils .NewLineCache (fsutils .NewFileCache ())
17
16
18
17
cfg := & config.LinterExclusions {
19
18
Rules : []config.ExcludeRule {
@@ -50,7 +49,7 @@ func TestExclusionRules_Process_multiple(t *testing.T) {
50
49
},
51
50
}
52
51
53
- p := NewExclusionRules (nil , files , cfg )
52
+ p := NewExclusionRules (nil , lines , cfg )
54
53
55
54
cases := []issueTestCase {
56
55
{Path : "e.go" , Text : "exclude" , Linter : "linter" },
@@ -91,52 +90,8 @@ func TestExclusionRules_Process_multiple(t *testing.T) {
91
90
assert .Equal (t , expectedCases , resultingCases )
92
91
}
93
92
94
- func TestExclusionRules_Process_pathPrefix (t * testing.T ) {
95
- files := fsutils .NewFiles (fsutils .NewLineCache (fsutils .NewFileCache ()), path .Join ("some" , "dir" ))
96
-
97
- cfg := & config.LinterExclusions {
98
- Rules : []config.ExcludeRule {
99
- {
100
- BaseRule : config.BaseRule {
101
- Path : `some/dir/e\.go` ,
102
- },
103
- },
104
- },
105
- }
106
-
107
- p := NewExclusionRules (nil , files , cfg )
108
-
109
- cases := []issueTestCase {
110
- {Path : "e.go" },
111
- {Path : "other.go" },
112
- }
113
-
114
- var issues []result.Issue
115
- for _ , c := range cases {
116
- issues = append (issues , newIssueFromIssueTestCase (c ))
117
- }
118
-
119
- processedIssues := process (t , p , issues ... )
120
-
121
- var resultingCases []issueTestCase
122
- for _ , i := range processedIssues {
123
- resultingCases = append (resultingCases , issueTestCase {
124
- Path : i .FilePath (),
125
- Linter : i .FromLinter ,
126
- Text : i .Text ,
127
- Line : i .Line (),
128
- })
129
- }
130
-
131
- expectedCases := []issueTestCase {
132
- {Path : "other.go" },
133
- }
134
-
135
- assert .Equal (t , expectedCases , resultingCases )
136
- }
137
-
138
93
func TestExclusionRules_Process_text (t * testing.T ) {
139
- files := fsutils .NewFiles ( fsutils . NewLineCache (fsutils .NewFileCache ()), "" )
94
+ lines := fsutils .NewLineCache (fsutils .NewFileCache ())
140
95
141
96
cfg := & config.LinterExclusions {
142
97
Rules : []config.ExcludeRule {{
@@ -147,7 +102,7 @@ func TestExclusionRules_Process_text(t *testing.T) {
147
102
}},
148
103
}
149
104
150
- p := NewExclusionRules (nil , files , cfg )
105
+ p := NewExclusionRules (nil , lines , cfg )
151
106
152
107
texts := []string {"exclude" , "1" , "" , "exclud" , "notexclude" }
153
108
var issues []result.Issue
@@ -170,15 +125,15 @@ func TestExclusionRules_Process_text(t *testing.T) {
170
125
}
171
126
172
127
func TestExclusionRules_Process_empty (t * testing.T ) {
173
- files := fsutils .NewFiles ( fsutils . NewLineCache (fsutils .NewFileCache ()), "" )
128
+ lines := fsutils .NewLineCache (fsutils .NewFileCache ())
174
129
175
- p := NewExclusionRules (nil , files , & config.LinterExclusions {})
130
+ p := NewExclusionRules (nil , lines , & config.LinterExclusions {})
176
131
177
132
processAssertSame (t , p , newIssueFromTextTestCase ("test" ))
178
133
}
179
134
180
135
func TestExclusionRules_Process_caseSensitive_multiple (t * testing.T ) {
181
- files := fsutils .NewFiles ( fsutils . NewLineCache (fsutils .NewFileCache ()), "" )
136
+ lines := fsutils .NewLineCache (fsutils .NewFileCache ())
182
137
183
138
cfg := & config.LinterExclusions {
184
139
Rules : []config.ExcludeRule {
@@ -209,7 +164,7 @@ func TestExclusionRules_Process_caseSensitive_multiple(t *testing.T) {
209
164
},
210
165
}
211
166
212
- p := NewExclusionRules (nil , files , cfg )
167
+ p := NewExclusionRules (nil , lines , cfg )
213
168
214
169
cases := []issueTestCase {
215
170
{Path : "e.go" , Text : "exclude" , Linter : "linter" },
@@ -253,7 +208,7 @@ func TestExclusionRules_Process_caseSensitive_multiple(t *testing.T) {
253
208
}
254
209
255
210
func TestExclusionRules_Process_caseSensitive_text (t * testing.T ) {
256
- files := fsutils .NewFiles ( fsutils . NewLineCache (fsutils .NewFileCache ()), "" )
211
+ lines := fsutils .NewLineCache (fsutils .NewFileCache ())
257
212
258
213
cfg := & config.LinterExclusions {
259
214
Rules : []config.ExcludeRule {
@@ -266,7 +221,7 @@ func TestExclusionRules_Process_caseSensitive_text(t *testing.T) {
266
221
},
267
222
}
268
223
269
- p := NewExclusionRules (nil , files , cfg )
224
+ p := NewExclusionRules (nil , lines , cfg )
270
225
271
226
texts := []string {"exclude" , "excLude" , "1" , "" , "exclud" , "notexclude" }
272
227
@@ -290,9 +245,9 @@ func TestExclusionRules_Process_caseSensitive_text(t *testing.T) {
290
245
}
291
246
292
247
func TestExclusionRules_Process_caseSensitive_empty (t * testing.T ) {
293
- files := fsutils .NewFiles ( fsutils . NewLineCache (fsutils .NewFileCache ()), "" )
248
+ lines := fsutils .NewLineCache (fsutils .NewFileCache ())
294
249
295
- p := NewExclusionRules (nil , files , & config.LinterExclusions {})
250
+ p := NewExclusionRules (nil , lines , & config.LinterExclusions {})
296
251
297
252
processAssertSame (t , p , newIssueFromTextTestCase ("test" ))
298
253
}
0 commit comments