Skip to content

Commit

Permalink
refactor: use execSync for tests (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Apr 4, 2019
1 parent 7327dbb commit 56fa69a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions cloud-tasks/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
rules:
no-console: off
node/no-missing-require: off
4 changes: 2 additions & 2 deletions cloud-tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"node": ">=8"
},
"scripts": {
"test": "mocha system-test"
"test": "mocha"
},
"dependencies": {
"@google-cloud/tasks": "^0.5.0",
Expand All @@ -17,7 +17,7 @@
"yargs": "^13.0.0"
},
"devDependencies": {
"execa": "^1.0.0",
"chai": "^4.2.0",
"mocha": "^6.0.0",
"uuid": "^3.3.2"
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,28 @@

'use strict';

const path = require('path');
const assert = require('assert');
const execa = require('execa');
const {assert} = require('chai');
const {execSync} = require('child_process');
const uuid = require('uuid');

const PROJECT_ID = process.env.GCLOUD_PROJECT;
const queueName = `gcloud-${uuid.v4().split('-')[0]}`;
const cwd = path.join(__dirname, '..');
const exec = cmd => execa.shell(cmd, {cwd});

describe('Cloud Task Sample Tests', () => {
it('should create a queue', async () => {
const {stdout} = await exec(`node createQueue ${PROJECT_ID} ${queueName}`);
assert.ok(stdout.includes('Created queue'));
it('should create a queue', () => {
const stdout = execSync(`node createQueue ${PROJECT_ID} ${queueName}`);
assert.match(stdout, /Created queue/);
});

it('should create a task', async () => {
const {stdout} = await exec(
it('should create a task', () => {
const stdout = execSync(
`node createTask --project=${PROJECT_ID} --location=us-central1 --queue=${queueName}`
);
assert.ok(stdout.includes('Created task'));
assert.match(stdout, /Created task/);
});

it('should delete a queue', async () => {
const {stdout} = await exec(`node deleteQueue ${PROJECT_ID} ${queueName}`);
assert.ok(stdout.includes('Deleted queue'));
it('should delete a queue', () => {
const stdout = execSync(`node deleteQueue ${PROJECT_ID} ${queueName}`);
assert.match(stdout, /Deleted queue/);
});
});

0 comments on commit 56fa69a

Please sign in to comment.