@@ -415,11 +415,8 @@ describe('pubsub', () => {
415415 subscription . on ( 'message' , ack ) ;
416416
417417 function ack ( message ) {
418- // remove listener to we only ack first message
419- subscription . removeListener ( 'message' , ack ) ;
420-
421418 message . ack ( ) ;
422- setTimeout ( ( ) => subscription . close ( done ) , 2500 ) ;
419+ subscription . close ( done ) ;
423420 }
424421 } ) ;
425422
@@ -430,11 +427,8 @@ describe('pubsub', () => {
430427 subscription . on ( 'message' , nack ) ;
431428
432429 function nack ( message ) {
433- // remove listener to we only ack first message
434- subscription . removeListener ( 'message' , nack ) ;
435-
436430 message . nack ( ) ;
437- setTimeout ( ( ) => subscription . close ( done ) , 2500 ) ;
431+ subscription . close ( done ) ;
438432 }
439433 } ) ;
440434
@@ -588,36 +582,32 @@ describe('pubsub', () => {
588582 let subscription ;
589583 let snapshot ;
590584
591- function deleteAllSnapshots ( ) {
592- // tslint:disable-next-line no-any
593- return ( pubsub . getSnapshots ( ) as any ) . then ( data => {
594- return Promise . all ( data [ 0 ] . map ( snapshot => {
595- return snapshot . delete ( ) ;
596- } ) ) ;
597- } ) ;
585+ function getSnapshotName ( { name} ) {
586+ return name . split ( '/' ) . pop ( ) ;
598587 }
599588
600589 before ( async ( ) => {
601590 topic = pubsub . topic ( generateTopicName ( ) ) ;
602591 subscription = topic . subscription ( generateSubName ( ) ) ;
603592 snapshot = subscription . snapshot ( SNAPSHOT_NAME ) ;
604593
605- await deleteAllSnapshots ( ) ;
606594 await topic . create ( ) ;
607595 await subscription . create ( ) ;
608596 await snapshot . create ( ) ;
609597 } ) ;
610598
611599 after ( async ( ) => {
612- await deleteAllSnapshots ( ) ;
600+ await snapshot . delete ( ) ;
601+ await subscription . delete ( ) ;
613602 await topic . delete ( ) ;
614603 } ) ;
615604
616605 it ( 'should get a list of snapshots' , done => {
617606 pubsub . getSnapshots ( ( err , snapshots ) => {
618607 assert . ifError ( err ) ;
619- assert . strictEqual ( snapshots . length , 1 ) ;
620- assert . strictEqual ( snapshots [ 0 ] . name . split ( '/' ) . pop ( ) , SNAPSHOT_NAME ) ;
608+ assert ( snapshots . length > 0 ) ;
609+ const names = snapshots . map ( getSnapshotName ) ;
610+ assert ( names . includes ( SNAPSHOT_NAME ) ) ;
621611 done ( ) ;
622612 } ) ;
623613 } ) ;
@@ -633,9 +623,9 @@ describe('pubsub', () => {
633623 snapshots . push ( snapshot ) ;
634624 } )
635625 . on ( 'end' , ( ) => {
636- assert . strictEqual ( snapshots . length , 1 ) ;
637- assert . strictEqual (
638- snapshots [ 0 ] . name . split ( '/' ) . pop ( ) , SNAPSHOT_NAME ) ;
626+ assert ( snapshots . length > 0 ) ;
627+ const names = snapshots . map ( getSnapshotName ) ;
628+ assert ( names . includes ( SNAPSHOT_NAME ) ) ;
639629 done ( ) ;
640630 } ) ;
641631 } ) ;
0 commit comments