@@ -23,7 +23,7 @@ import {
2323 Topic ,
2424} from '@google-cloud/pubsub' ;
2525import { assert } from 'chai' ;
26- import { describe , it , afterEach } from 'mocha' ;
26+ import { describe , it , after } from 'mocha' ;
2727import * as cp from 'child_process' ;
2828import * as uuid from 'uuid' ;
2929import * as path from 'path' ;
@@ -40,9 +40,9 @@ describe('schema', () => {
4040 const pubsub = new PubSub ( { projectId} ) ;
4141 const runId = uuid . v4 ( ) ;
4242 console . log ( `Topics runId: ${ runId } ` ) ;
43- const topicIdStem = `schema-top-${ runId } ` ;
44- const subscriptionIdStem = `schema-sub-${ runId } ` ;
45- const schemaIdStem = `schema-${ runId } ` ;
43+ const topicIdStem = `schema-top-${ runId } - ` ;
44+ const subscriptionIdStem = `schema-sub-${ runId } - ` ;
45+ const schemaIdStem = `schema-${ runId } - ` ;
4646
4747 // Schemas have a delay between deletion and actual deletion, so
4848 // we have to make unique schema names. It's simplest to do it for topics
@@ -68,32 +68,32 @@ describe('schema', () => {
6868
6969 const commandFor = ( action : string ) => `node ${ action } .js` ;
7070
71- async function cleanSchemas ( ) {
71+ async function cleanAllSchemas ( ) {
7272 const schemas = [ ] ;
7373 for await ( const s of pubsub . listSchemas ( ) ) {
7474 schemas . push ( pubsub . schema ( s . name ! ) . delete ( ) ) ;
7575 }
7676 await Promise . all ( schemas ) ;
7777 }
7878
79- async function cleanTopics ( ) {
79+ async function cleanAllTopics ( ) {
8080 const [ topics ] = await pubsub . getTopics ( ) ;
8181 await Promise . all (
8282 topics . filter ( x => x . name . endsWith ( runId ) ) . map ( x => x . delete ( ) )
8383 ) ;
8484 }
8585
86- async function cleanSubs ( ) {
86+ async function cleanAllSubs ( ) {
8787 const [ subscriptions ] = await pubsub . getSubscriptions ( ) ;
8888 await Promise . all (
8989 subscriptions . filter ( x => x . name . endsWith ( runId ) ) . map ( x => x . delete ( ) )
9090 ) ;
9191 }
9292
93- afterEach ( async ( ) => {
94- await cleanSubs ( ) ;
95- await cleanTopics ( ) ;
96- await cleanSchemas ( ) ;
93+ after ( async ( ) => {
94+ await cleanAllSubs ( ) ;
95+ await cleanAllTopics ( ) ;
96+ await cleanAllSchemas ( ) ;
9797 } ) ;
9898
9999 function fixturePath ( fixture : string ) : string {
@@ -202,12 +202,13 @@ describe('schema', () => {
202202 assert . include ( output , schema . id ) ;
203203 assert . include ( output , 'deleted.' ) ;
204204
205- try {
205+ // Because of caching delays, this can't be deterministic without a big wait.
206+ /*try {
206207 const got = await pubsub.schema(schema.id).get();
207208 assert.isNotOk(got, "schema hadn't been deleted");
208209 } catch (e) {
209210 // This is expected.
210- }
211+ }*/
211212 } ) ;
212213
213214 it ( 'should get a schema' , async ( ) => {
0 commit comments