Skip to content

Commit 9720e08

Browse files
committed
Write tests
1 parent fa8a93a commit 9720e08

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/client/lib/cluster/index.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ describe('Cluster', () => {
235235

236236
assert.equal(cluster.pubSubNode, undefined);
237237
}, GLOBAL.CLUSTERS.OPEN);
238+
239+
testUtils.testWithCluster('concurrent unsubscribe does not throw an error', async cluster => {
240+
const listener = spy();
241+
242+
await cluster.subscribe('channel', listener);
243+
await cluster.subscribe('channel2', listener);
244+
245+
await Promise.all([
246+
cluster.unsubscribe('channel', listener),
247+
cluster.unsubscribe('channel2', listener)
248+
]);
249+
250+
assert.equal(cluster.isOpen, false);
251+
}, GLOBAL.CLUSTERS.OPEN);
238252

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

340+
testUtils.testWithCluster('concurrent sunsubscribe does not throw an error', async cluster => {
341+
const listener = spy();
342+
343+
await cluster.sSubscribe('channel', listener);
344+
await cluster.sSubscribe('channel2', listener);
345+
346+
await Promise.all([
347+
cluster.sUnsubscribe('channel', listener),
348+
cluster.sUnsubscribe('channel2', listener)
349+
])
350+
351+
352+
assert.equal(cluster.isOpen, false);
353+
}, {
354+
...GLOBAL.CLUSTERS.OPEN,
355+
minimumDockerVersion: [7]
356+
});
357+
326358
testUtils.testWithCluster('should handle sharded-channel-moved events', async cluster => {
327359
const SLOT = 10328,
328360
migrating = cluster.slots[SLOT].master,

0 commit comments

Comments
 (0)