Skip to content

Commit 2223f1a

Browse files
JustinBeckwithAce Nassri
authored and
Ace Nassri
committed
refactor: use execSync for tests (#69)
1 parent db7a2a5 commit 2223f1a

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

scheduler/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
},
2121
"devDependencies": {
2222
"chai": "^4.2.0",
23-
"execa": "^1.0.0",
2423
"mocha": "^6.0.0",
2524
"supertest": "^4.0.0"
2625
}

scheduler/system-test/test.samples.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
'use strict';
1616

17-
const path = require('path');
1817
const {assert} = require('chai');
19-
const execa = require('execa');
18+
const {execSync} = require('child_process');
2019
const supertest = require('supertest');
2120
const app = require('../app.js');
2221
const request = supertest(app);
@@ -25,22 +24,22 @@ const PROJECT_ID = process.env.GCLOUD_PROJECT;
2524
const LOCATION_ID = process.env.LOCATION_ID || 'us-central1';
2625
const SERVICE_ID = 'my-service';
2726

28-
const cwd = path.join(__dirname, '../');
29-
const exec = cmd => execa.shell(cmd, {cwd});
30-
3127
describe('Cloud Scheduler Sample Tests', () => {
3228
let jobName;
3329

3430
it('should create and delete a scheduler job', async () => {
35-
const {stdout} = await exec(
31+
const stdout = execSync(
3632
`node createJob.js ${PROJECT_ID} ${LOCATION_ID} ${SERVICE_ID}`
3733
);
3834
assert.match(stdout, /Created job/);
39-
jobName = stdout.split('/').pop();
35+
jobName = stdout
36+
.toString()
37+
.split('/')
38+
.pop();
4039
});
4140

4241
it('should delete a scheduler job', async () => {
43-
const {stdout} = await exec(
42+
const stdout = execSync(
4443
`node deleteJob.js ${PROJECT_ID} ${LOCATION_ID} ${jobName}`
4544
);
4645
assert.match(stdout, /Job deleted/);

0 commit comments

Comments
 (0)