chore(): resolve conflicts

This commit is contained in:
Kamil Myśliwiec
2021-06-29 14:46:05 +02:00
3 changed files with 29 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import * as request from 'supertest';
import { Test } from '@nestjs/testing';
import { MultiStoreModule } from '../src/multi-store/multi-store.module';
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { MultiStoreModule } from '../src/multi-store/multi-store.module';
describe('Caching Multi Store', () => {
let server;
@@ -17,16 +17,12 @@ describe('Caching Multi Store', () => {
await app.init();
});
it(`Should return empty`, async () => {
return request(server)
.get('/')
.expect(200, '');
it(`should return empty`, async () => {
return request(server).get('/').expect(200, '');
});
it(`Should return data`, async () => {
return request(server)
.get('/')
.expect(200, 'multi-store-value');
it(`should return data`, async () => {
return request(server).get('/').expect(200, 'multi-store-value');
});
after(async () => {

View File

@@ -27,10 +27,19 @@ export class KafkaParser {
return data;
}
public decode(value: Buffer): object | string | null {
public decode(value: Buffer): object | string | null | Buffer {
if (isNil(value)) {
return null;
}
// A value with the "leading zero byte" indicates the schema payload.
// The "content" is possibly binary and should not be touched & parsed.
if (
Buffer.isBuffer(value) &&
value.length > 0 &&
value.readUInt8(0) === 0
) {
return value;
}
let result = value.toString();
const startChar = result.charAt(0);

View File

@@ -43,6 +43,18 @@ describe('KafkaParser', () => {
});
});
it('binary buffer using kafka schema registry preamble', () => {
const kafkaSchemaPreambleWithSchemaId = [0x00, 0x00, 0x00, 0x00, 0x01];
expect(
KafkaParser.parse({
value: Buffer.from(kafkaSchemaPreambleWithSchemaId),
}),
).to.deep.eq({
headers: {},
value: Buffer.from(kafkaSchemaPreambleWithSchemaId),
});
});
it('buffer number', () => {
expect(
kafkaParser.parse({