@@ -29,31 +29,23 @@ func Test_GetPriorityShouldReturnDefaultPriorityIfNotEnabledOrInvalidQueryString
29
29
30
30
type testCase struct {
31
31
query string
32
- err error
33
32
queryPriorityEnabled bool
34
33
}
35
34
36
35
tests := map [string ]testCase {
37
36
"should miss if query priority not enabled" : {
38
37
query : "up" ,
39
- err : errQueryPriorityDisabled ,
40
38
},
41
39
"should miss if query string empty" : {
42
40
query : "" ,
43
- err : errEmptyQueryString ,
44
41
queryPriorityEnabled : true ,
45
42
},
46
43
}
47
44
48
45
for testName , testData := range tests {
49
46
t .Run (testName , func (t * testing.T ) {
50
47
limits .queryPriority .Enabled = testData .queryPriorityEnabled
51
- priority , err := GetPriority (testData .query , 0 , 0 , now , limits .queryPriority )
52
- if err != nil {
53
- assert .Equal (t , testData .err , err )
54
- } else {
55
- assert .NoError (t , err )
56
- }
48
+ priority := GetPriority (testData .query , 0 , 0 , now , limits .queryPriority )
57
49
assert .Equal (t , int64 (0 ), priority )
58
50
})
59
51
}
@@ -111,8 +103,7 @@ func Test_GetPriorityShouldConsiderRegex(t *testing.T) {
111
103
t .Run (testName , func (t * testing.T ) {
112
104
limits .queryPriority .Priorities [0 ].QueryAttributes [0 ].Regex = testData .regex
113
105
limits .queryPriority .Priorities [0 ].QueryAttributes [0 ].CompiledRegex = regexp .MustCompile (testData .regex )
114
- priority , err := GetPriority (testData .query , 0 , 0 , now , limits .queryPriority )
115
- assert .NoError (t , err )
106
+ priority := GetPriority (testData .query , 0 , 0 , now , limits .queryPriority )
116
107
assert .Equal (t , int64 (testData .expectedPriority ), priority )
117
108
})
118
109
}
@@ -180,8 +171,7 @@ func Test_GetPriorityShouldConsiderStartAndEndTime(t *testing.T) {
180
171
181
172
for testName , testData := range tests {
182
173
t .Run (testName , func (t * testing.T ) {
183
- priority , err := GetPriority ("sum(up)" , testData .start .UnixMilli (), testData .end .UnixMilli (), now , limits .queryPriority )
184
- assert .NoError (t , err )
174
+ priority := GetPriority ("sum(up)" , testData .start .UnixMilli (), testData .end .UnixMilli (), now , limits .queryPriority )
185
175
assert .Equal (t , int64 (testData .expectedPriority ), priority )
186
176
})
187
177
}
@@ -225,8 +215,7 @@ func Test_GetPriorityShouldNotConsiderStartAndEndTimeIfEmpty(t *testing.T) {
225
215
226
216
for testName , testData := range tests {
227
217
t .Run (testName , func (t * testing.T ) {
228
- priority , err := GetPriority ("sum(up)" , testData .start .Unix (), testData .end .Unix (), now , limits .queryPriority )
229
- assert .NoError (t , err )
218
+ priority := GetPriority ("sum(up)" , testData .start .Unix (), testData .end .Unix (), now , limits .queryPriority )
230
219
assert .Equal (t , int64 (1 ), priority )
231
220
})
232
221
}
0 commit comments