@@ -307,7 +307,8 @@ describe('exchange', () => {
307
307
308
308
const channelWithReply = connection . connection . channels . filter ( ( channel ) => channel . channel . reply ) ;
309
309
Assert . lengthOf ( channelWithReply , 0 ) ;
310
- done ( ) ;
310
+
311
+ deleteExchange ( exchange , ( ) => done ( ) ) ;
311
312
} ) ;
312
313
} ) ;
313
314
@@ -321,7 +322,8 @@ describe('exchange', () => {
321
322
const channelWithReply = connection . connection . channels . filter ( ( channel ) => channel . channel . reply ) ;
322
323
Assert . lengthOf ( channelWithReply , 1 ) ;
323
324
Assert . exists ( channelWithReply [ 0 ] . channel . reply ) ;
324
- done ( ) ;
325
+
326
+ deleteExchange ( exchange , ( ) => done ( ) ) ;
325
327
} ) ;
326
328
} ) ;
327
329
@@ -341,7 +343,10 @@ describe('exchange', () => {
341
343
Assert . equal ( message , data ) ;
342
344
Assert . equal ( msg . fields . routingKey , finalKey ) ;
343
345
ack ( ) ;
344
- queue . cancel ( done ) ;
346
+
347
+ queue . cancel ( ( ) => {
348
+ deleteExchange ( exchange , ( ) => done ( ) ) ;
349
+ } ) ;
345
350
} ) ;
346
351
347
352
queue . once ( 'bound' , ( ) => {
@@ -369,3 +374,14 @@ describe('exchange', () => {
369
374
} ) ;
370
375
} ) ;
371
376
} ) ;
377
+
378
+ function deleteExchange ( exchange , callback ) {
379
+ const { channel } = exchange . getInternals ( )
380
+ channel . deleteExchange ( exchange . name , { } , ( error ) => {
381
+ if ( error ) {
382
+ console . log ( `WARN: failed to delete exchange "${ exchange . name } " -- ${ error . stack ?? error . message ?? 'unspecified error' } ` ) ;
383
+ }
384
+
385
+ callback ( error , ! error ) ;
386
+ } ) ;
387
+ }
0 commit comments