14
14
15
15
'use strict' ;
16
16
17
- const path = require ( 'path' ) ;
18
17
const { assert} = require ( 'chai' ) ;
19
- const execa = require ( 'execa ' ) ;
18
+ const { execSync } = require ( 'child_process ' ) ;
20
19
const supertest = require ( 'supertest' ) ;
21
20
const app = require ( '../app.js' ) ;
22
21
const request = supertest ( app ) ;
@@ -25,22 +24,22 @@ const PROJECT_ID = process.env.GCLOUD_PROJECT;
25
24
const LOCATION_ID = process . env . LOCATION_ID || 'us-central1' ;
26
25
const SERVICE_ID = 'my-service' ;
27
26
28
- const cwd = path . join ( __dirname , '../' ) ;
29
- const exec = cmd => execa . shell ( cmd , { cwd} ) ;
30
-
31
27
describe ( 'Cloud Scheduler Sample Tests' , ( ) => {
32
28
let jobName ;
33
29
34
30
it ( 'should create and delete a scheduler job' , async ( ) => {
35
- const { stdout} = await exec (
31
+ const stdout = execSync (
36
32
`node createJob.js ${ PROJECT_ID } ${ LOCATION_ID } ${ SERVICE_ID } `
37
33
) ;
38
34
assert . match ( stdout , / C r e a t e d j o b / ) ;
39
- jobName = stdout . split ( '/' ) . pop ( ) ;
35
+ jobName = stdout
36
+ . toString ( )
37
+ . split ( '/' )
38
+ . pop ( ) ;
40
39
} ) ;
41
40
42
41
it ( 'should delete a scheduler job' , async ( ) => {
43
- const { stdout} = await exec (
42
+ const stdout = execSync (
44
43
`node deleteJob.js ${ PROJECT_ID } ${ LOCATION_ID } ${ jobName } `
45
44
) ;
46
45
assert . match ( stdout , / J o b d e l e t e d / ) ;
0 commit comments