Skip to content

Commit 4b7265e

Browse files
Merge pull request #238 from OlivierCazade/fix-timereceived-tests
Fix tests after new timereceived field
2 parents c418a01 + ac34ff8 commit 4b7265e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/pipeline/ingest/ingest_kafka_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ func Test_NewIngestKafka2(t *testing.T) {
9999
require.Equal(t, defaultBatchReadTimeout, ingestKafka.kafkaParams.BatchReadTimeout)
100100
}
101101

102+
func removeTimestamp(receivedEntries []config.GenericMap) {
103+
for _, entry := range receivedEntries {
104+
delete(entry, "TimeReceived")
105+
}
106+
}
107+
102108
func Test_IngestKafka(t *testing.T) {
103109
newIngest := initNewIngestKafka(t, testConfig1)
104110
ingestKafka := newIngest.(*ingestKafka)
@@ -124,6 +130,10 @@ func Test_IngestKafka(t *testing.T) {
124130
// wait for the data to have been processed
125131
receivedEntries := <-ingestOutput
126132

133+
// we remove timestamp for test stability
134+
// Timereceived field is tested in the decodeJson tests
135+
removeTimestamp(receivedEntries)
136+
127137
require.Equal(t, 3, len(receivedEntries))
128138
require.Equal(t, test.DeserializeJSONToMap(t, record1), receivedEntries[0])
129139
require.Equal(t, test.DeserializeJSONToMap(t, record2), receivedEntries[1])
@@ -175,6 +185,10 @@ func Test_KafkaListener(t *testing.T) {
175185
// wait for the data to have been processed
176186
receivedEntries := <-ingestOutput
177187

188+
// we remove timestamp for test stability
189+
// Timereceived field is tested in the decodeJson tests
190+
removeTimestamp(receivedEntries)
191+
178192
require.Equal(t, 1, len(receivedEntries))
179193
require.Equal(t, test.DeserializeJSONToMap(t, string(fakeRecord)), receivedEntries[0])
180194
}

0 commit comments

Comments
 (0)