From 532d97bdb2287ab4ee29d4c34ee082247c891b86 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Wed, 12 Dec 2018 22:58:43 -0800 Subject: [PATCH] fix: fix sample tests (#79) --- asset/snippets/package.json | 13 +++---------- asset/snippets/system-test/quickstart.test.js | 19 ++++++++----------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/asset/snippets/package.json b/asset/snippets/package.json index 359ae4253b..0b2d6e52c5 100644 --- a/asset/snippets/package.json +++ b/asset/snippets/package.json @@ -1,7 +1,6 @@ { "name": "@google-cloud/asset-samples", "description": "Samples for the Cloud Asset API Client Library for Node.js.", - "version": "0.0.1", "license": "Apache-2.0", "author": "Google Inc.", "engines": { @@ -12,24 +11,18 @@ ], "repository": "googleapis/nodejs-asset", "private": true, - "nyc": { - "exclude": [ - "**/*.test.js" - ] - }, "scripts": { "test": "mocha system-test --timeout 20000" }, "dependencies": { "@google-cloud/asset": "^0.1.1", "@google-cloud/storage": "^2.3.0", - "express": "^4.16.4", "uuid": "^3.3.2", "yargs": "^12.0.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.0.0", - "mocha": "^5.2.0", - "sinon": "^7.0.0" + "chai": "^4.2.0", + "execa": "^1.0.0", + "mocha": "^5.2.0" } } diff --git a/asset/snippets/system-test/quickstart.test.js b/asset/snippets/system-test/quickstart.test.js index 6066942c03..e04aa190ea 100644 --- a/asset/snippets/system-test/quickstart.test.js +++ b/asset/snippets/system-test/quickstart.test.js @@ -15,21 +15,20 @@ 'use strict'; -const assert = require('assert'); +const {assert} = require('chai'); const path = require('path'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); +const execa = require('execa'); +const {Storage} = require('@google-cloud/storage'); + const cwd = path.join(__dirname, '..'); const cmd = 'node quickstart.js'; -const {Storage} = require('@google-cloud/storage'); - const storage = new Storage(); const bucketName = `asset-nodejs-${uuid.v4()}`; const bucket = storage.bucket(bucketName); describe('quickstart sample tests', () => { - before(tools.checkCredentials); before(async () => { await bucket.create(); }); @@ -40,7 +39,7 @@ describe('quickstart sample tests', () => { it('should export assets to specified path', async () => { const dumpFilePath = `gs://${bucketName}/my-assets.txt`; - await tools.runAsyncWithIO(`${cmd} export-assets ${dumpFilePath}`, cwd); + await execa.shell(`${cmd} export-assets ${dumpFilePath}`, {cwd}); const file = await bucket.file('my-assets.txt'); const exists = await file.exists(); assert.ok(exists); @@ -49,12 +48,10 @@ describe('quickstart sample tests', () => { it('should get assets history successfully', async () => { const assetName = `//storage.googleapis.com/${bucketName}`; - const output = await tools.runAsyncWithIO( + const {stdout} = await execa.shell( `${cmd} batch-get-history ${assetName}`, - cwd + {cwd} ); - if (output.stdout) { - assert.ok(output.stdout.includes(assetName)); - } + assert.match(stdout, new RegExp(assetName)); }); });