MCPcopy
hub / github.com/mongodb/node-mongodb-native / test

Function test

test/integration/node-specific/abort_signal.test.ts:303–345  ·  test/integration/node-specific/abort_signal.test.ts::test
(cursorAPI, args)

Source from the content-addressed store, hash-verified

301 const metadata: MongoDBMetadataUI = { requires: { topology: class="st">'replicaset' } };
302
303 function test(cursorAPI, args) {
304 let controller: AbortController;
305 let signal: AbortSignal;
306 let cursor: AbstractCursor<{ a: number }>;
307
308 beforeEach(() => {
309 controller = new AbortController();
310 signal = controller.signal;
311 cursor = method(filter, {
312 signal,
313 class="cm">// Pick an unselectable server
314 readPreference: new ReadPreference(class="st">'secondary', [
315 { something: class="st">'that does not exist' }
316 ])
317 });
318 });
319
320 afterEach(async () => {
321 await cursor?.close();
322 });
323
324 it(`rejects ${cursorAPI.toString()}`, metadata, async () => {
325 const willBeResult = iterateUntilDocumentOrError(cursor, cursorAPI, args);
326
327 await sleep(3);
328 expect(
329 findLast(
330 logs,
331 l =>
332 l.operation === cursorName &&
333 l.message === class="st">'Waiting for suitable server to become available'
334 )
335 ).to.exist;
336
337 controller.abort();
338 const start = performance.now();
339 const result = await willBeResult;
340 const end = performance.now();
341 expect(end - start).to.be.lessThan(10); class="cm">// should be way less than 5s server selection timeout
342
343 expect(result).to.be.instanceOf(DOMException);
344 });
345 }
346
347 for (const [cursorAPI, { value: args }] of getAllProps(cursorAPIs)) {
348 test(cursorAPI, args);

Callers 1

testCursorFunction · 0.70

Calls 13

findLastFunction · 0.90
configureFailPointFunction · 0.90
clearFailPointFunction · 0.90
itFunction · 0.85
onceMethod · 0.80
applyMethod · 0.80
onMethod · 0.80
emitMethod · 0.65
closeMethod · 0.45
toStringMethod · 0.45
abortMethod · 0.45

Tested by

no test coverage detected