Skip to content

Commit

Permalink
refactor: use execSync for tests (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored and Ace Nassri committed Nov 15, 2022
1 parent 05f2808 commit 84241d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"devDependencies": {
"chai": "^4.2.0",
"execa": "^1.0.0",
"mocha": "^6.0.0",
"supertest": "^4.0.0"
}
Expand Down
15 changes: 7 additions & 8 deletions scheduler/system-test/test.samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

'use strict';

const path = require('path');
const {assert} = require('chai');
const execa = require('execa');
const {execSync} = require('child_process');
const supertest = require('supertest');
const app = require('../app.js');
const request = supertest(app);
Expand All @@ -25,22 +24,22 @@ const PROJECT_ID = process.env.GCLOUD_PROJECT;
const LOCATION_ID = process.env.LOCATION_ID || 'us-central1';
const SERVICE_ID = 'my-service';

const cwd = path.join(__dirname, '../');
const exec = cmd => execa.shell(cmd, {cwd});

describe('Cloud Scheduler Sample Tests', () => {
let jobName;

it('should create and delete a scheduler job', async () => {
const {stdout} = await exec(
const stdout = execSync(
`node createJob.js ${PROJECT_ID} ${LOCATION_ID} ${SERVICE_ID}`
);
assert.match(stdout, /Created job/);
jobName = stdout.split('/').pop();
jobName = stdout
.toString()
.split('/')
.pop();
});

it('should delete a scheduler job', async () => {
const {stdout} = await exec(
const stdout = execSync(
`node deleteJob.js ${PROJECT_ID} ${LOCATION_ID} ${jobName}`
);
assert.match(stdout, /Job deleted/);
Expand Down

0 comments on commit 84241d4

Please sign in to comment.