@@ -303,18 +303,32 @@ describe('pubsub', () => {
303303 projectId = await client . getProjectId ( ) ;
304304 formattedParent = `projects/${ projectId } ` ;
305305 formattedNoteName = `projects/${ projectId } /notes/${ noteId } ` ;
306- try {
307- // attempt to create topic if missing
308- await pubsub . createTopic ( topicName ) ;
309- } catch ( err ) {
310- console . log ( `topic creation failed: ${ topicName } ` ) ;
311- }
312306 topic = pubsub . topic ( topicName ) ;
313307 } ) ;
314308
315309 describe ( 'occurrences from pubsub subscription' , ( ) => {
316- before ( async ( ) => {
317- await topic . createSubscription ( subscriptionId ) ;
310+ it ( 'should get count of occurrences from pubsub topic' , async function ( ) {
311+ this . retries ( 3 ) ;
312+ await delay ( this . test ) ;
313+ try {
314+ // attempt to create topic if missing
315+ await pubsub . createTopic ( topicName ) ;
316+ } catch ( err ) {
317+ console . log ( `topic creation failed: ${ topicName } ${ err . message } ` ) ;
318+ if ( ! err . message . includes ( 'ALREADY_EXISTS' ) ) {
319+ throw err ;
320+ }
321+ }
322+ try {
323+ await topic . createSubscription ( subscriptionId ) ;
324+ } catch ( err ) {
325+ console . log (
326+ `subscription creation failed: ${ subscriptionId } ${ err . message } `
327+ ) ;
328+ if ( ! err . message . includes ( 'ALREADY_EXISTS' ) ) {
329+ throw err ;
330+ }
331+ }
318332 const pubSubNoteReq = {
319333 parent : formattedParent ,
320334 noteId : `${ noteId } -pubsub` ,
@@ -336,12 +350,6 @@ describe('pubsub', () => {
336350 } ,
337351 } ;
338352 await client . getGrafeasClient ( ) . createNote ( pubSubNoteReq ) ;
339- } ) ;
340-
341- it ( 'should get count of occurrences from pubsub topic' , async function ( ) {
342- this . retries ( 3 ) ;
343- await delay ( this . test ) ;
344-
345353 const occurrenceCount = 3 ;
346354 const pubSubOccurrenceReq = {
347355 parent : formattedParent ,
@@ -389,7 +397,7 @@ describe('pubsub', () => {
389397 assert . match ( output , / P o l l e d [ 1 - 9 ] + o c c u r r e n c e s / ) ;
390398 } ) ;
391399
392- it ( 'should delete the pubsub subscription' , async function ( ) {
400+ it ( 'should delete the pubsub subscription' , async function ( ) {
393401 this . retries ( 3 ) ;
394402 await delay ( this . test ) ;
395403
0 commit comments