From df35469ea903e131c99f1b4ce3e4452a49c15976 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 11 Apr 2019 18:16:55 -0700 Subject: [PATCH] refactor: use execSync for tests (#286) --- compute/package.json | 1 - compute/test/samples.test.js | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compute/package.json b/compute/package.json index bf147e68b2..cab76851f0 100644 --- a/compute/package.json +++ b/compute/package.json @@ -22,7 +22,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "execa": "^1.0.0", "mocha": "^6.0.0", "proxyquire": "^2.0.1", "uuid": "^3.2.1" diff --git a/compute/test/samples.test.js b/compute/test/samples.test.js index 9c76232e98..0a5d168f48 100644 --- a/compute/test/samples.test.js +++ b/compute/test/samples.test.js @@ -16,18 +16,19 @@ 'use strict'; const uuid = require('uuid'); -const execa = require('execa'); +const cp = require('child_process'); const {assert} = require('chai'); const Compute = require('@google-cloud/compute'); -const exec = async cmd => (await execa.shell(cmd)).stdout; +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + const compute = new Compute(); describe('quickstart', () => { const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`; after(async () => deleteVM(name)); it('should run the quickstart', async () => { - const output = await exec(`node quickstart ${name}`); + const output = execSync(`node quickstart ${name}`); assert.match(output, /Virtual machine created!/); }); }); @@ -36,17 +37,17 @@ describe('lifecycle', async () => { const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`; it('should create a VM', async () => { - const output = await exec(`node createVM ${name}`); + const output = execSync(`node createVM ${name}`); assert.match(output, /Virtual machine created!/); }); it('should list the VMs', async () => { - const output = await exec('node listVMs'); + const output = execSync('node listVMs'); assert.match(output, /Found \d+ VMs!/); }); it('should delete the VM', async () => { - const output = await exec(`node deleteVM ${name}`); + const output = execSync(`node deleteVM ${name}`); assert.match(output, /VM deleted!/); }); }); @@ -55,8 +56,8 @@ describe('start-up script', async () => { const name = `gcloud-apache-${uuid.v4().split('-')[0]}`; after(async () => deleteVM(name)); it('should create vm with startup script', async () => { - const output = await exec(`node startupScript ${name}`); - assert.match(output, /created succesfully$/); + const output = execSync(`node startupScript ${name}`); + assert.match(output, /created succesfully/); }); });