Skip to content

Commit

Permalink
refactor: use execSync for tests (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Apr 5, 2019
1 parent 71fea10 commit ce1140c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions asset/snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"repository": "googleapis/nodejs-asset",
"private": true,
"scripts": {
"test": "mocha system-test --timeout 20000"
"test": "mocha --timeout 20000"
},
"dependencies": {
"@google-cloud/asset": "^0.3.0",
Expand All @@ -22,7 +22,6 @@
},
"devDependencies": {
"chai": "^4.2.0",
"execa": "^1.0.0",
"mocha": "^6.0.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
'use strict';

const {assert} = require('chai');
const path = require('path');
const uuid = require('uuid');
const execa = require('execa');
const cp = require('child_process');
const {Storage} = require('@google-cloud/storage');

const cwd = path.join(__dirname, '..');
const cmd = 'node quickstart.js';
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = 'node quickstart.js';
const storage = new Storage();
const bucketName = `asset-nodejs-${uuid.v4()}`;
const bucket = storage.bucket(bucketName);
Expand All @@ -39,7 +38,7 @@ describe('quickstart sample tests', () => {

it('should export assets to specified path', async () => {
const dumpFilePath = `gs://${bucketName}/my-assets.txt`;
await execa.shell(`${cmd} export-assets ${dumpFilePath}`, {cwd});
execSync(`${cmd} export-assets ${dumpFilePath}`);
const file = await bucket.file('my-assets.txt');
const exists = await file.exists();
assert.ok(exists);
Expand All @@ -48,10 +47,7 @@ describe('quickstart sample tests', () => {

it('should get assets history successfully', async () => {
const assetName = `//storage.googleapis.com/${bucketName}`;
const {stdout} = await execa.shell(
`${cmd} batch-get-history ${assetName}`,
{cwd}
);
const stdout = execSync(`${cmd} batch-get-history ${assetName}`);
assert.match(stdout, new RegExp(assetName));
});
});

0 comments on commit ce1140c

Please sign in to comment.