15
15
16
16
'use strict' ;
17
17
18
- const assert = require ( 'assert ' ) ;
18
+ const { assert} = require ( 'chai ' ) ;
19
19
const path = require ( 'path' ) ;
20
- const tools = require ( '@google-cloud/nodejs-repo-tools' ) ;
21
20
const uuid = require ( 'uuid' ) ;
21
+ const execa = require ( 'execa' ) ;
22
+ const { Storage} = require ( '@google-cloud/storage' ) ;
23
+
22
24
const cwd = path . join ( __dirname , '..' ) ;
23
25
const cmd = 'node quickstart.js' ;
24
26
25
- const { Storage} = require ( '@google-cloud/storage' ) ;
26
-
27
27
const storage = new Storage ( ) ;
28
28
const bucketName = `asset-nodejs-${ uuid . v4 ( ) } ` ;
29
29
const bucket = storage . bucket ( bucketName ) ;
30
30
31
31
describe ( 'quickstart sample tests' , ( ) => {
32
- before ( tools . checkCredentials ) ;
33
32
before ( async ( ) => {
34
33
await bucket . create ( ) ;
35
34
} ) ;
@@ -40,7 +39,7 @@ describe('quickstart sample tests', () => {
40
39
41
40
it ( 'should export assets to specified path' , async ( ) => {
42
41
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} ) ;
44
43
const file = await bucket . file ( 'my-assets.txt' ) ;
45
44
const exists = await file . exists ( ) ;
46
45
assert . ok ( exists ) ;
@@ -49,12 +48,10 @@ describe('quickstart sample tests', () => {
49
48
50
49
it ( 'should get assets history successfully' , async ( ) => {
51
50
const assetName = `//storage.googleapis.com/${ bucketName } ` ;
52
- const output = await tools . runAsyncWithIO (
51
+ const { stdout } = await execa . shell (
53
52
`${ cmd } batch-get-history ${ assetName } ` ,
54
- cwd
53
+ { cwd}
55
54
) ;
56
- if ( output . stdout ) {
57
- assert . ok ( output . stdout . includes ( assetName ) ) ;
58
- }
55
+ assert . match ( stdout , new RegExp ( assetName ) ) ;
59
56
} ) ;
60
57
} ) ;
0 commit comments