Skip to content

Commit

Permalink
Refactor Redis testing factories for consistency and clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP committed Dec 16, 2024
1 parent 83186b2 commit 68a2670
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
5 changes: 2 additions & 3 deletions src/infra/redis/testing/stream-message-reply.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ export const streamMessageReplyFactory = Factory.define<StreamMessageReply>(({ s
return {
id: `redis-id-${sequence}`,
message: {
key: `redis-key-${sequence}-1`,
m: Buffer.from(`message-${sequence}-2`),
docName: `doc-name-${sequence}`,
compact: Buffer.from(`compact-${sequence}`),
docName: `prefix:room:room:docid-${sequence.toString()}`,
compact: Buffer.from(`prefix:room:room:docid-${sequence.toString()}`),
},
};
});
14 changes: 1 addition & 13 deletions src/infra/redis/testing/x-auto-claim-response.factory.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { Factory } from 'fishery';
import { StreamMessageReply, XAutoClaimResponse } from '../interfaces/index.js';
import { XAutoClaimResponse } from '../interfaces/index.js';

export const xAutoClaimResponseFactory = Factory.define<XAutoClaimResponse>(({ sequence }) => {
return {
nextId: sequence.toString(),
messages: [],
};
});

export const streamMessageReplyFactory = Factory.define<StreamMessageReply>(({ sequence }) => {
return {
id: sequence.toString(),
message: {
key: sequence.toString(),
m: Buffer.from(sequence.toString()),
docName: `prefix:room:room:docid-${sequence.toString()}`,
compact: Buffer.from(`prefix:room:room:docid-${sequence.toString()}`),
},
};
});
6 changes: 2 additions & 4 deletions src/modules/worker/worker.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { Awareness } from 'y-protocols/awareness';
import { Doc } from 'yjs';
import { Logger } from '../../infra/logger/logger.js';
import { RedisAdapter, StreamMessageReply } from '../../infra/redis/interfaces/index.js';
import {
streamMessageReplyFactory,
xAutoClaimResponseFactory,
} from '../../infra/redis/testing/x-auto-claim-response.factory.js';
import { streamMessageReplyFactory } from '../../infra/redis/testing/stream-message-reply.factory.js';
import { xAutoClaimResponseFactory } from '../../infra/redis/testing/x-auto-claim-response.factory.js';
import { StorageService } from '../../infra/storage/storage.service.js';
import { yRedisDocFactory } from '../../infra/y-redis/testing/y-redis-doc.factory.js';
import { YRedisClient } from '../../infra/y-redis/y-redis.client.js';
Expand Down

0 comments on commit 68a2670

Please sign in to comment.