1515
1616'use strict' ;
1717
18- const assert = require ( 'assert ' ) ;
18+ const { assert} = require ( 'chai ' ) ;
1919const path = require ( 'path' ) ;
20- const tools = require ( '@google-cloud/nodejs-repo-tools' ) ;
2120const uuid = require ( 'uuid' ) ;
21+ const execa = require ( 'execa' ) ;
22+ const { Storage} = require ( '@google-cloud/storage' ) ;
23+
2224const cwd = path . join ( __dirname , '..' ) ;
2325const cmd = 'node quickstart.js' ;
2426
25- const { Storage} = require ( '@google-cloud/storage' ) ;
26-
2727const storage = new Storage ( ) ;
2828const bucketName = `asset-nodejs-${ uuid . v4 ( ) } ` ;
2929const bucket = storage . bucket ( bucketName ) ;
3030
3131describe ( 'quickstart sample tests' , ( ) => {
32- before ( tools . checkCredentials ) ;
3332 before ( async ( ) => {
3433 await bucket . create ( ) ;
3534 } ) ;
@@ -40,7 +39,7 @@ describe('quickstart sample tests', () => {
4039
4140 it ( 'should export assets to specified path' , async ( ) => {
4241 const dumpFilePath = `gs://${ bucketName } /my-assets.txt` ;
43- await tools . runAsyncWithIO ( `${ cmd } export-assets ${ dumpFilePath } ` , cwd ) ;
42+ await execa . shell ( `${ cmd } export-assets ${ dumpFilePath } ` , { cwd} ) ;
4443 const file = await bucket . file ( 'my-assets.txt' ) ;
4544 const exists = await file . exists ( ) ;
4645 assert . ok ( exists ) ;
@@ -49,12 +48,10 @@ describe('quickstart sample tests', () => {
4948
5049 it ( 'should get assets history successfully' , async ( ) => {
5150 const assetName = `//storage.googleapis.com/${ bucketName } ` ;
52- const output = await tools . runAsyncWithIO (
51+ const { stdout } = await execa . shell (
5352 `${ cmd } batch-get-history ${ assetName } ` ,
54- cwd
53+ { cwd}
5554 ) ;
56- if ( output . stdout ) {
57- assert . ok ( output . stdout . includes ( assetName ) ) ;
58- }
55+ assert . match ( stdout , new RegExp ( assetName ) ) ;
5956 } ) ;
6057} ) ;
0 commit comments