From 2836bd25d263161279b9a0f187c3ff4d74c86d05 Mon Sep 17 00:00:00 2001 From: peter-zheng-g <43967553+peter-zheng-g@users.noreply.github.com> Date: Tue, 27 Nov 2018 15:27:25 -0800 Subject: [PATCH] sample: Add quickstart sample code for BatchGetAsstesHistory. (#59) --- asset/snippets/system-test/quickstart.test.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/asset/snippets/system-test/quickstart.test.js b/asset/snippets/system-test/quickstart.test.js index de7fa6d803..6066942c03 100644 --- a/asset/snippets/system-test/quickstart.test.js +++ b/asset/snippets/system-test/quickstart.test.js @@ -18,7 +18,6 @@ const assert = require('assert'); const path = require('path'); const tools = require('@google-cloud/nodejs-repo-tools'); -const util = require('util'); const uuid = require('uuid'); const cwd = path.join(__dirname, '..'); const cmd = 'node quickstart.js'; @@ -29,20 +28,33 @@ const storage = new Storage(); const bucketName = `asset-nodejs-${uuid.v4()}`; const bucket = storage.bucket(bucketName); -describe('Quickstart sample tests', () => { +describe('quickstart sample tests', () => { + before(tools.checkCredentials); before(async () => { - tools.checkCredentials(); await bucket.create(); }); - after(async () => await bucket.delete()); + after(async () => { + await bucket.delete(); + }); it('should export assets to specified path', async () => { - const dumpFilePath = util.format('gs://%s/my-assets.txt', bucketName); + const dumpFilePath = `gs://${bucketName}/my-assets.txt`; await tools.runAsyncWithIO(`${cmd} export-assets ${dumpFilePath}`, cwd); const file = await bucket.file('my-assets.txt'); - const [exists] = await file.exists(); + const exists = await file.exists(); assert.ok(exists); await file.delete(); }); + + it('should get assets history successfully', async () => { + const assetName = `//storage.googleapis.com/${bucketName}`; + const output = await tools.runAsyncWithIO( + `${cmd} batch-get-history ${assetName}`, + cwd + ); + if (output.stdout) { + assert.ok(output.stdout.includes(assetName)); + } + }); });