Skip to content

Commit

Permalink
fix(client): XAUTOCLAIM after a TRIM returns nil
Browse files Browse the repository at this point in the history
  • Loading branch information
Calyhre committed Jul 10, 2023
1 parent a7d5bc7 commit 0d8d05e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
57 changes: 33 additions & 24 deletions packages/client/lib/commands/generic-transformers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,30 +194,39 @@ describe('Generic Transformers', () => {
);
});

it('transformStreamMessagesReply', () => {
assert.deepEqual(
transformStreamMessagesReply([['0-0', ['0key', '0value']], ['1-0', ['1key', '1value']]]),
[{
id: '0-0',
message: Object.create(null, {
'0key': {
value: '0value',
configurable: true,
enumerable: true
}
})
}, {
id: '1-0',
message: Object.create(null, {
'1key': {
value: '1value',
configurable: true,
enumerable: true
}
})
}]
);
});
describe('transformStreamMessagesReply', () => {
it('with null', () => {
assert.deepEqual(
transformStreamMessagesReply([null]),
[]
);
})

it('with messages', () => {
assert.deepEqual(
transformStreamMessagesReply([['0-0', ['0key', '0value']], ['1-0', ['1key', '1value']]]),
[{
id: '0-0',
message: Object.create(null, {
'0key': {
value: '0value',
configurable: true,
enumerable: true
}
})
}, {
id: '1-0',
message: Object.create(null, {
'1key': {
value: '1value',
configurable: true,
enumerable: true
}
})
}]
);
})
})

describe('transformStreamsMessagesReply', () => {
it('null', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/client/lib/commands/generic-transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export type StreamMessagesReply = Array<StreamMessageReply>;
export function transformStreamMessagesReply(reply: Array<any>): StreamMessagesReply {
const messages = [];

if (reply[0] === null) {
return messages;
}

for (const [id, message] of reply) {
messages.push({
id,
Expand Down

0 comments on commit 0d8d05e

Please sign in to comment.