Skip to content

Commit 69b58b1

Browse files
refactor: use execSync for tests (#127)
1 parent 86d8843 commit 69b58b1

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

asset/snippets/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"repository": "googleapis/nodejs-asset",
1313
"private": true,
1414
"scripts": {
15-
"test": "mocha system-test --timeout 20000"
15+
"test": "mocha --timeout 20000"
1616
},
1717
"dependencies": {
1818
"@google-cloud/asset": "^0.3.0",
@@ -22,7 +22,6 @@
2222
},
2323
"devDependencies": {
2424
"chai": "^4.2.0",
25-
"execa": "^1.0.0",
2625
"mocha": "^6.0.0"
2726
}
2827
}
File renamed without changes.

asset/snippets/system-test/quickstart.test.js renamed to asset/snippets/test/quickstart.test.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
'use strict';
1717

1818
const {assert} = require('chai');
19-
const path = require('path');
2019
const uuid = require('uuid');
21-
const execa = require('execa');
20+
const cp = require('child_process');
2221
const {Storage} = require('@google-cloud/storage');
2322

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

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

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

4948
it('should get assets history successfully', async () => {
5049
const assetName = `//storage.googleapis.com/${bucketName}`;
51-
const {stdout} = await execa.shell(
52-
`${cmd} batch-get-history ${assetName}`,
53-
{cwd}
54-
);
50+
const stdout = execSync(`${cmd} batch-get-history ${assetName}`);
5551
assert.match(stdout, new RegExp(assetName));
5652
});
5753
});

0 commit comments

Comments
 (0)