Skip to content

Commit be86110

Browse files
committed
test: update diagnostics_channel suppression tests for lazy storage
Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
1 parent b84cfb7 commit be86110

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,29 @@ const { AsyncLocalStorage } = require('async_hooks');
159159
const key = Symbol('store');
160160
const ch = channel('test-suppression-store');
161161
const als = new AsyncLocalStorage();
162+
const normalAls = new AsyncLocalStorage();
162163

164+
// Normal store — should always be entered
165+
ch.bindStore(normalAls, common.mustCall((data) => data));
166+
167+
// Bypass store — should be skipped inside suppressed()
168+
ch.bindStore(als, common.mustNotCall(), { subscriberId: key });
169+
170+
// Normal subscriber — verifies normal store entered, bypass store skipped
163171
const handler = common.mustCall(() => {
172+
assert.strictEqual(normalAls.getStore()?.entered, true);
164173
assert.strictEqual(als.getStore(), undefined);
165174
});
166175

167176
ch.subscribe(handler);
168-
ch.bindStore(als, common.mustNotCall(), { subscriberId: key });
169177

170178
suppressed(key, common.mustCall(() => {
171-
ch.publish({});
179+
ch.publish({ entered: true });
172180
}));
173181

174182
ch.unsubscribe(handler);
175183
ch.unbindStore(als);
184+
ch.unbindStore(normalAls);
176185
}
177186

178187
// Test 9: Wrong type for subscriberId throws ERR_INVALID_ARG_TYPE

0 commit comments

Comments
 (0)