@@ -79,38 +79,37 @@ func TestSyncFlushStageExec(t *testing.T) {
79
79
skipGroupKey bool
80
80
skipNow bool
81
81
skipGroupWait bool
82
- expectedErr bool
82
+ expectedErr error
83
83
}{
84
84
{
85
85
name : "no entries" ,
86
86
sync : true ,
87
87
entries : []* nflogpb.Entry {},
88
88
pipelineTime : now ,
89
- expectedErr : false ,
90
89
},
91
90
{
92
91
name : "missing group key" ,
93
92
sync : true ,
94
93
entries : []* nflogpb.Entry {},
95
94
pipelineTime : now ,
96
95
skipGroupKey : true ,
97
- expectedErr : true ,
96
+ expectedErr : ErrMissingGroupKey ,
98
97
},
99
98
{
100
99
name : "missing now" ,
101
100
sync : true ,
102
101
entries : []* nflogpb.Entry {},
103
102
pipelineTime : now ,
104
103
skipNow : true ,
105
- expectedErr : true ,
104
+ expectedErr : ErrMissingNow ,
106
105
},
107
106
{
108
107
name : "missing group wait" ,
109
108
sync : true ,
110
109
entries : []* nflogpb.Entry {},
111
110
pipelineTime : now ,
112
111
skipGroupWait : true ,
113
- expectedErr : true ,
112
+ expectedErr : ErrMissingGroupInterval ,
114
113
},
115
114
{
116
115
name : "entry exists but no wait needed" ,
@@ -122,7 +121,6 @@ func TestSyncFlushStageExec(t *testing.T) {
122
121
},
123
122
},
124
123
pipelineTime : now ,
125
- expectedErr : false ,
126
124
},
127
125
{
128
126
name : "entry exists and wait would be needed" ,
@@ -134,7 +132,6 @@ func TestSyncFlushStageExec(t *testing.T) {
134
132
},
135
133
},
136
134
pipelineTime : now ,
137
- expectedErr : false ,
138
135
},
139
136
{
140
137
name : "sync disabled" ,
@@ -146,7 +143,6 @@ func TestSyncFlushStageExec(t *testing.T) {
146
143
},
147
144
},
148
145
pipelineTime : now ,
149
- expectedErr : false ,
150
146
},
151
147
{
152
148
name : "context timeout" ,
@@ -159,7 +155,7 @@ func TestSyncFlushStageExec(t *testing.T) {
159
155
},
160
156
pipelineTime : now ,
161
157
contextTimeout : 50 * time .Millisecond ,
162
- expectedErr : true ,
158
+ expectedErr : context . DeadlineExceeded ,
163
159
},
164
160
{
165
161
name : "multiple entries error" ,
@@ -175,7 +171,7 @@ func TestSyncFlushStageExec(t *testing.T) {
175
171
},
176
172
},
177
173
pipelineTime : now ,
178
- expectedErr : true ,
174
+ expectedErr : ErrUnexpectedEntryResultSize ,
179
175
},
180
176
}
181
177
@@ -212,12 +208,8 @@ func TestSyncFlushStageExec(t *testing.T) {
212
208
alerts := []* types.Alert {{}, {}}
213
209
_ , gotAlerts , err := stage .Exec (ctx , log .NewNopLogger (), alerts ... )
214
210
215
- if tc .expectedErr {
216
- assert .Error (t , err )
217
- } else {
218
- assert .NoError (t , err )
219
- assert .Equal (t , alerts , gotAlerts )
220
- }
211
+ assert .Equal (t , alerts , gotAlerts )
212
+ assert .ErrorIs (t , err , tc .expectedErr )
221
213
})
222
214
}
223
215
}
@@ -264,3 +256,4 @@ func TestNewSyncFlushStage(t *testing.T) {
264
256
})
265
257
}
266
258
}
259
+
0 commit comments