Skip to content

Commit

Permalink
Address code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksmaus committed May 28, 2024
1 parent 8799002 commit 1db7467
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions reassembler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ type results struct {
events []eventMeta
}

func testPayloadForMessage(msg *auparse.AuditMessage) map[string]interface{} {
return map[string]interface{}{
"seq": msg.Sequence,
"typ": msg.RecordType,
}
}

func testReassembler(t testing.TB, file string, expected *results) {
f, err := os.Open(file)
if err != nil {
Expand All @@ -136,7 +129,7 @@ func testReassembler(t testing.TB, file string, expected *results) {
}

// Attach some predictable Payload
msg.Payload = testPayloadForMessage(msg)
msg.Payload = createTestPayload(msg)

reassmbler.PushMessage(msg)
}
Expand All @@ -156,12 +149,19 @@ func testReassembler(t testing.TB, file string, expected *results) {
assert.EqualValues(t, expectedEvent.seq, msg.Sequence, "sequence number")

// Verify that custom payload is preserved
assert.Equal(t, testPayloadForMessage(msg), msg.Payload)
assert.Equal(t, createTestPayload(msg), msg.Payload)
}
assert.Equal(t, expectedEvent.count, len(stream.events[i]), "message count")
}
}

func createTestPayload(msg *auparse.AuditMessage) map[string]interface{} {
return map[string]interface{}{
"seq": msg.Sequence,
"typ": msg.RecordType,
}
}

func TestSequenceNumSliceSort(t *testing.T) {
expected := sequenceNumSlice{maxSeq - 5, maxSeq - 4, maxSeq - 3, maxSeq - 2, maxSeq, 0, 1, 2, 3, 4}
seqs := sequenceNumSlice{maxSeq - 5, maxSeq - 4, 0, 1, 2, maxSeq - 3, maxSeq - 2, maxSeq, 3, 4}
Expand Down

0 comments on commit 1db7467

Please sign in to comment.