mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-29 03:04:16 +01:00
616389713b
Revert "chore: use rdkafka consumer for analytics ingestion and onEvent (#15432)"
This reverts commit 85bb582cee
.
28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
import { convertKafkaJSHeadersToRdKafkaHeaders } from '../../src/utils/db/kafka-producer-wrapper'
|
|
|
|
test('can convert from KafkaJS headers to rdkafka headers', () => {
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders()).toEqual([])
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({})).toEqual([])
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: 'bar' })).toEqual([{ foo: Buffer.from('bar') }])
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: ['bar', 'baz'] })).toEqual([
|
|
{ foo: Buffer.from('bar') },
|
|
{ foo: Buffer.from('baz') },
|
|
])
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: ['bar', 'baz'], qux: 'quux' })).toEqual([
|
|
{ foo: Buffer.from('bar') },
|
|
{ foo: Buffer.from('baz') },
|
|
{ qux: Buffer.from('quux') },
|
|
])
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: undefined })).toEqual([])
|
|
|
|
// We should be able to use strings and Buffers interchangeably
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: Buffer.from('bar') })).toEqual([{ foo: Buffer.from('bar') }])
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: 'bar' })).toEqual([{ foo: Buffer.from('bar') }])
|
|
|
|
// We should be able to use strings and Buffers interchangeably in arrays
|
|
expect(convertKafkaJSHeadersToRdKafkaHeaders({ foo: [Buffer.from('bar'), 'baz'] })).toEqual([
|
|
{ foo: Buffer.from('bar') },
|
|
{ foo: Buffer.from('baz') },
|
|
])
|
|
})
|