1616'use strict' ;
1717
1818const { assert} = require ( 'chai' ) ;
19- const path = require ( 'path' ) ;
2019const uuid = require ( 'uuid' ) ;
21- const execa = require ( 'execa ' ) ;
20+ const cp = require ( 'child_process ' ) ;
2221const { Storage} = require ( '@google-cloud/storage' ) ;
2322
24- const cwd = path . join ( __dirname , '..' ) ;
25- const cmd = 'node quickstart.js' ;
23+ const execSync = cmd => cp . execSync ( cmd , { encoding : 'utf-8' } ) ;
2624
25+ const cmd = 'node quickstart.js' ;
2726const storage = new Storage ( ) ;
2827const bucketName = `asset-nodejs-${ uuid . v4 ( ) } ` ;
2928const bucket = storage . bucket ( bucketName ) ;
@@ -39,7 +38,7 @@ describe('quickstart sample tests', () => {
3938
4039 it ( 'should export assets to specified path' , async ( ) => {
4140 const dumpFilePath = `gs://${ bucketName } /my-assets.txt` ;
42- await execa . shell ( `${ cmd } export-assets ${ dumpFilePath } ` , { cwd } ) ;
41+ execSync ( `${ cmd } export-assets ${ dumpFilePath } ` ) ;
4342 const file = await bucket . file ( 'my-assets.txt' ) ;
4443 const exists = await file . exists ( ) ;
4544 assert . ok ( exists ) ;
@@ -48,10 +47,7 @@ describe('quickstart sample tests', () => {
4847
4948 it ( 'should get assets history successfully' , async ( ) => {
5049 const assetName = `//storage.googleapis.com/${ bucketName } ` ;
51- const { stdout} = await execa . shell (
52- `${ cmd } batch-get-history ${ assetName } ` ,
53- { cwd}
54- ) ;
50+ const stdout = execSync ( `${ cmd } batch-get-history ${ assetName } ` ) ;
5551 assert . match ( stdout , new RegExp ( assetName ) ) ;
5652 } ) ;
5753} ) ;
0 commit comments