Skip to content

Commit b496a1a

Browse files
fix: fix sample tests (#79)
1 parent c6b3424 commit b496a1a

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

asset/snippets/package.json

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@google-cloud/asset-samples",
33
"description": "Samples for the Cloud Asset API Client Library for Node.js.",
4-
"version": "0.0.1",
54
"license": "Apache-2.0",
65
"author": "Google Inc.",
76
"engines": {
@@ -12,24 +11,18 @@
1211
],
1312
"repository": "googleapis/nodejs-asset",
1413
"private": true,
15-
"nyc": {
16-
"exclude": [
17-
"**/*.test.js"
18-
]
19-
},
2014
"scripts": {
2115
"test": "mocha system-test --timeout 20000"
2216
},
2317
"dependencies": {
2418
"@google-cloud/asset": "^0.1.1",
2519
"@google-cloud/storage": "^2.3.0",
26-
"express": "^4.16.4",
2720
"uuid": "^3.3.2",
2821
"yargs": "^12.0.0"
2922
},
3023
"devDependencies": {
31-
"@google-cloud/nodejs-repo-tools": "^3.0.0",
32-
"mocha": "^5.2.0",
33-
"sinon": "^7.0.0"
24+
"chai": "^4.2.0",
25+
"execa": "^1.0.0",
26+
"mocha": "^5.2.0"
3427
}
3528
}

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

+8-11
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515

1616
'use strict';
1717

18-
const assert = require('assert');
18+
const {assert} = require('chai');
1919
const path = require('path');
20-
const tools = require('@google-cloud/nodejs-repo-tools');
2120
const uuid = require('uuid');
21+
const execa = require('execa');
22+
const {Storage} = require('@google-cloud/storage');
23+
2224
const cwd = path.join(__dirname, '..');
2325
const cmd = 'node quickstart.js';
2426

25-
const {Storage} = require('@google-cloud/storage');
26-
2727
const storage = new Storage();
2828
const bucketName = `asset-nodejs-${uuid.v4()}`;
2929
const bucket = storage.bucket(bucketName);
3030

3131
describe('quickstart sample tests', () => {
32-
before(tools.checkCredentials);
3332
before(async () => {
3433
await bucket.create();
3534
});
@@ -40,7 +39,7 @@ describe('quickstart sample tests', () => {
4039

4140
it('should export assets to specified path', async () => {
4241
const dumpFilePath = `gs://${bucketName}/my-assets.txt`;
43-
await tools.runAsyncWithIO(`${cmd} export-assets ${dumpFilePath}`, cwd);
42+
await execa.shell(`${cmd} export-assets ${dumpFilePath}`, {cwd});
4443
const file = await bucket.file('my-assets.txt');
4544
const exists = await file.exists();
4645
assert.ok(exists);
@@ -49,12 +48,10 @@ describe('quickstart sample tests', () => {
4948

5049
it('should get assets history successfully', async () => {
5150
const assetName = `//storage.googleapis.com/${bucketName}`;
52-
const output = await tools.runAsyncWithIO(
51+
const {stdout} = await execa.shell(
5352
`${cmd} batch-get-history ${assetName}`,
54-
cwd
53+
{cwd}
5554
);
56-
if (output.stdout) {
57-
assert.ok(output.stdout.includes(assetName));
58-
}
55+
assert.match(stdout, new RegExp(assetName));
5956
});
6057
});

0 commit comments

Comments
 (0)