@@ -70,20 +70,20 @@ func TestLogEventBatch(t *testing.T) {
7070 t .Run ("HasSpace" , func (t * testing.T ) {
7171 batch := newLogEventBatch (Target {Group : "G" , Stream : "S" }, nil )
7272
73+ event := newLogEvent (time .Now (), "Test message" , nil )
74+ maxEvents := reqSizeLimit / event .eventBytes
75+
7376 // Add events until close to the limit
74- for i := 0 ; i < reqEventsLimit - 1 ; i ++ {
75- event := newLogEvent (time .Now (), "Test message" , nil )
77+ for i := 0 ; i < maxEvents - 1 ; i ++ {
7678 batch .append (event )
7779 }
7880
79- assert .True (t , batch .hasSpace (100 ), "Batch should have space for one more small event" )
80- assert .False (t , batch .hasSpace (reqSizeLimit ), "Batch should not have space for an event that exceeds the size limit" )
81+ assert .True (t , batch .hasSpace (event .eventBytes ))
8182
8283 // Add one more event to reach the limit
83- event := newLogEvent (time .Now (), "Last message" , nil )
8484 batch .append (event )
8585
86- assert .False (t , batch .hasSpace (1 ), "Batch should not have space after reaching event limit" )
86+ assert .False (t , batch .hasSpace (event . eventBytes ) )
8787 })
8888
8989 t .Run ("Build" , func (t * testing.T ) {
0 commit comments