@@ -152,7 +152,8 @@ func TestReadWindowsEventLogger(t *testing.T) {
152
152
err = logger .Info (10 , logMessage )
153
153
require .NoError (t , err )
154
154
155
- records := requireExpectedLogRecords (t , sink , src , 1 )
155
+ records := assertExpectedLogRecords (t , sink , src , 1 )
156
+ require .Len (t , records , 1 )
156
157
record := records [0 ]
157
158
body := record .Body ().Map ().AsRaw ()
158
159
@@ -205,7 +206,8 @@ func TestReadWindowsEventLoggerRaw(t *testing.T) {
205
206
err = logger .Info (10 , logMessage )
206
207
require .NoError (t , err )
207
208
208
- records := requireExpectedLogRecords (t , sink , src , 1 )
209
+ records := assertExpectedLogRecords (t , sink , src , 1 )
210
+ require .Len (t , records , 1 )
209
211
record := records [0 ]
210
212
body := record .Body ().AsString ()
211
213
bodyStruct := struct {
@@ -272,8 +274,8 @@ func TestExcludeProvider(t *testing.T) {
272
274
require .NoError (t , err )
273
275
}
274
276
275
- records := requireExpectedLogRecords (t , sink , notExcludedSrc , 1 )
276
- assert .NotEmpty (t , records )
277
+ records := assertExpectedLogRecords (t , sink , notExcludedSrc , 1 )
278
+ assert .Len (t , records , 1 )
277
279
278
280
records = filterAllLogRecordsBySource (t , sink , excludedSrc )
279
281
assert .Empty (t , records )
@@ -319,13 +321,13 @@ func assertEventSourceInstallation(t *testing.T, src string) (uninstallEventSour
319
321
return
320
322
}
321
323
322
- func requireExpectedLogRecords (t * testing.T , sink * consumertest.LogsSink , expectedEventSrc string , expectedEventCount int ) []plog.LogRecord {
324
+ func assertExpectedLogRecords (t * testing.T , sink * consumertest.LogsSink , expectedEventSrc string , expectedEventCount int ) []plog.LogRecord {
323
325
var actualLogRecords []plog.LogRecord
324
326
325
327
// logs sometimes take a while to be written, so a substantial wait buffer is needed
326
- require .EventuallyWithT (t , func (c * assert.CollectT ) {
328
+ assert .EventuallyWithT (t , func (c * assert.CollectT ) {
327
329
actualLogRecords = filterAllLogRecordsBySource (t , sink , expectedEventSrc )
328
- require .Len (c , actualLogRecords , expectedEventCount )
330
+ assert .Len (c , actualLogRecords , expectedEventCount )
329
331
}, 10 * time .Second , 250 * time .Millisecond )
330
332
331
333
return actualLogRecords
0 commit comments