Skip to content

Commit

Permalink
Merge branch 'main' into BC-8431
Browse files Browse the repository at this point in the history
  • Loading branch information
bergatco authored Nov 25, 2024
2 parents 0065923 + f36cf22 commit 82ce14f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/infra/redis/ioredis.adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from '../logger/index.js';
import { IoRedisAdapter } from './ioredis.adapter.js';
import { RedisConfig } from './redis.config.js';
import { xAutoClaimRawReplyFactory } from './testing/x-auto-claim-raw-reply.factory.js';
import { xItemsBufferFactory } from './testing/x-items.factory.js';
import { xItemsStringFactory } from './testing/x-items.factory.js';
import { xReadBufferReplyFactory } from './testing/x-read-buffer-reply.factory.js';

describe(IoRedisAdapter.name, () => {
Expand Down Expand Up @@ -358,33 +358,33 @@ describe(IoRedisAdapter.name, () => {
const setup = async () => {
const { redisAdapter, redis } = await buildParams();
const redisDeleteStreamName = `${testPrefix}:delete`;
const xrangeBufferSpy = jest.spyOn(redis, 'xrangeBuffer');
const xrangeSpy = jest.spyOn(redis, 'xrange');

const xrangeBufferReply = xItemsBufferFactory.build();
const xrangeReply = xItemsStringFactory.build();

// @ts-ignore
xrangeBufferSpy.mockResolvedValue(xrangeBufferReply);
xrangeSpy.mockResolvedValue(xrangeReply);

const [id, fields] = xrangeBufferReply[0];
const [id, fields] = xrangeReply[0];

const expectedProps = [redisDeleteStreamName, '-', '+'];

const expectedReturn = [
{
id: id.toString(),
message: { message: fields[1] },
message: { key: fields[1] },
},
];

return { xrangeBufferSpy, redisDeleteStreamName, expectedProps, expectedReturn, redisAdapter };
return { xrangeSpy, redisDeleteStreamName, expectedProps, expectedReturn, redisAdapter };
};

it('should call redis xrangeBuffer with correct values', async () => {
const { xrangeBufferSpy, expectedProps, redisAdapter } = await setup();
it('should call redis xrange with correct values', async () => {
const { xrangeSpy, expectedProps, redisAdapter } = await setup();

await redisAdapter.getDeletedDocEntries();

expect(xrangeBufferSpy).toHaveBeenCalledWith(...expectedProps);
expect(xrangeSpy).toHaveBeenCalledWith(...expectedProps);
});

it('should return correct value', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/infra/redis/ioredis.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class IoRedisAdapter implements RedisAdapter {
}

public async getDeletedDocEntries(): Promise<StreamMessageReply[]> {
const deletedDocEntries = await this.redis.xrangeBuffer(this.redisDeleteStreamName, '-', '+');
const deletedDocEntries = await this.redis.xrange(this.redisDeleteStreamName, '-', '+');

const transformedDeletedTasks = mapToStreamMessagesReplies(deletedDocEntries);

Expand Down

0 comments on commit 82ce14f

Please sign in to comment.