Skip to content

Commit b8194af

Browse files
committed
test: wrap suppressed callbacks with common.mustCall
Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
1 parent 9468795 commit b8194af

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

test/parallel/test-diagnostics-channel-suppression.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const { AsyncLocalStorage } = require('async_hooks');
1212
const handler = common.mustNotCall();
1313
ch.subscribe(handler, { subscriberId: key });
1414

15-
suppressed(key, () => {
15+
suppressed(key, common.mustCall(() => {
1616
ch.publish({});
17-
});
17+
}));
1818

1919
ch.unsubscribe(handler);
2020
}
@@ -28,9 +28,9 @@ const { AsyncLocalStorage } = require('async_hooks');
2828
ch.subscribe(optedHandler, { subscriberId: key });
2929
ch.subscribe(regularHandler); // no suppression
3030

31-
suppressed(key, () => {
31+
suppressed(key, common.mustCall(() => {
3232
ch.publish({});
33-
});
33+
}));
3434

3535
ch.unsubscribe(optedHandler);
3636
ch.unsubscribe(regularHandler);
@@ -48,16 +48,16 @@ const { AsyncLocalStorage } = require('async_hooks');
4848
ch.subscribe(h1, { subscriberId: k1 });
4949
ch.subscribe(h2, { subscriberId: k2 });
5050

51-
suppressed(k1, () => {
51+
suppressed(k1, common.mustCall(() => {
5252
ch.publish({});
53-
});
53+
}));
5454

5555
assert.strictEqual(h1Calls, 0);
5656
assert.strictEqual(h2Calls, 1);
5757

58-
suppressed(k2, () => {
58+
suppressed(k2, common.mustCall(() => {
5959
ch.publish({});
60-
});
60+
}));
6161

6262
assert.strictEqual(h1Calls, 1);
6363
assert.strictEqual(h2Calls, 1);
@@ -103,12 +103,14 @@ const { AsyncLocalStorage } = require('async_hooks');
103103
const ch = channel('test-suppression-promise');
104104
const handler = common.mustNotCall();
105105
ch.subscribe(handler, { subscriberId: key });
106+
const done = common.mustCall();
106107

107-
suppressed(key, async () => {
108+
suppressed(key, common.mustCall(async () => {
108109
await Promise.resolve();
109110
ch.publish({});
110-
}).then(common.mustCall(() => {
111+
})).then(common.mustCall(() => {
111112
ch.unsubscribe(handler);
113+
done();
112114
}));
113115
}
114116

@@ -118,20 +120,22 @@ const { AsyncLocalStorage } = require('async_hooks');
118120
const ch = channel('test-suppression-timers');
119121
const handler = common.mustNotCall();
120122
ch.subscribe(handler, { subscriberId: key });
123+
const done = common.mustCall();
121124

122-
suppressed(key, async () => {
125+
suppressed(key, common.mustCall(async () => {
123126
await new Promise((resolve) => {
124-
setImmediate(() => {
127+
setImmediate(common.mustCall(() => {
125128
ch.publish({});
126129

127-
queueMicrotask(() => {
130+
queueMicrotask(common.mustCall(() => {
128131
ch.publish({});
129132
resolve();
130-
});
131-
});
133+
}));
134+
}));
132135
});
133-
}).then(common.mustCall(() => {
136+
})).then(common.mustCall(() => {
134137
ch.unsubscribe(handler);
138+
done();
135139
}));
136140
}
137141

@@ -144,9 +148,9 @@ const { AsyncLocalStorage } = require('async_hooks');
144148
ch.unsubscribe(handler);
145149

146150
// Should not throw and should not be called
147-
suppressed(key, () => {
151+
suppressed(key, common.mustCall(() => {
148152
ch.publish({});
149-
});
153+
}));
150154

151155
}
152156

@@ -163,9 +167,9 @@ const { AsyncLocalStorage } = require('async_hooks');
163167
ch.subscribe(handler);
164168
ch.bindStore(als, common.mustNotCall(), { subscriberId: key });
165169

166-
suppressed(key, () => {
170+
suppressed(key, common.mustCall(() => {
167171
ch.publish({});
168-
});
172+
}));
169173

170174
ch.unsubscribe(handler);
171175
ch.unbindStore(als);
@@ -196,5 +200,3 @@ const { AsyncLocalStorage } = require('async_hooks');
196200
}), receiver, 'a', 'b');
197201
assert.strictEqual(result, 42);
198202
}
199-
200-
console.log('ok - diagnostics_channel suppression tests loaded');

0 commit comments

Comments
 (0)