Skip to content

Commit

Permalink
Write tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentLayne committed Jan 10, 2024
1 parent fa8a93a commit 9720e08
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/client/lib/cluster/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ describe('Cluster', () => {

assert.equal(cluster.pubSubNode, undefined);
}, GLOBAL.CLUSTERS.OPEN);

testUtils.testWithCluster('concurrent unsubscribe does not throw an error', async cluster => {
const listener = spy();

await cluster.subscribe('channel', listener);
await cluster.subscribe('channel2', listener);

await Promise.all([
cluster.unsubscribe('channel', listener),
cluster.unsubscribe('channel2', listener)
]);

assert.equal(cluster.isOpen, false);
}, GLOBAL.CLUSTERS.OPEN);

testUtils.testWithCluster('psubscribe & punsubscribe', async cluster => {
const listener = spy();
Expand Down Expand Up @@ -323,6 +337,24 @@ describe('Cluster', () => {
minimumDockerVersion: [7]
});

testUtils.testWithCluster('concurrent sunsubscribe does not throw an error', async cluster => {
const listener = spy();

await cluster.sSubscribe('channel', listener);
await cluster.sSubscribe('channel2', listener);

await Promise.all([
cluster.sUnsubscribe('channel', listener),
cluster.sUnsubscribe('channel2', listener)
])


assert.equal(cluster.isOpen, false);
}, {
...GLOBAL.CLUSTERS.OPEN,
minimumDockerVersion: [7]
});

testUtils.testWithCluster('should handle sharded-channel-moved events', async cluster => {
const SLOT = 10328,
migrating = cluster.slots[SLOT].master,
Expand Down

0 comments on commit 9720e08

Please sign in to comment.