From cb9115ebc95c98c6fd6b14dc4df584c3ce46b488 Mon Sep 17 00:00:00 2001 From: "F. Hinkelmann" Date: Wed, 27 Nov 2019 12:30:57 -0500 Subject: [PATCH] Remove repo-tools from several samples (#1554) --- cloud-tasks/function/package.json | 1 - datacatalog/cloud-client/package.json | 13 -------- .../system-test/createEntryGroup.test.js | 26 +++++++++++---- .../system-test/createFilesetEntry.test.js | 33 ++++++++++++------- .../system-test/lookupEntry.test.js | 26 +++++++++++---- datastore/functions/package.json | 4 --- storage-transfer/package.json | 18 ++-------- storage-transfer/system-test/transfer.test.js | 10 +++++- 8 files changed, 70 insertions(+), 61 deletions(-) diff --git a/cloud-tasks/function/package.json b/cloud-tasks/function/package.json index 0bf18c9caf..4d365bcf77 100644 --- a/cloud-tasks/function/package.json +++ b/cloud-tasks/function/package.json @@ -13,7 +13,6 @@ "@sendgrid/mail": "^6.4.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.3.0", "mocha": "^6.0.0", "proxyquire": "^2.1.0", "sinon": "^7.0.0" diff --git a/datacatalog/cloud-client/package.json b/datacatalog/cloud-client/package.json index 5cc098a1fd..2aa37d4ffa 100644 --- a/datacatalog/cloud-client/package.json +++ b/datacatalog/cloud-client/package.json @@ -13,23 +13,10 @@ "test": "mocha system-test/*.test.js --timeout=60000" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.3.0", "mocha": "^6.0.0", "uuid": "^3.1.0" }, "dependencies": { "@google-cloud/datacatalog": "^1.3.0" - }, - "cloud-repo-tools": { - "requiresKeyFile": true, - "requiresProjectId": true, - "test": { - "build": { - "requiredEnvVars": [ - "GCLOUD_PROJECT", - "GCLOUD_DATASET_ID" - ] - } - } } } diff --git a/datacatalog/cloud-client/system-test/createEntryGroup.test.js b/datacatalog/cloud-client/system-test/createEntryGroup.test.js index 18f9b9d297..86aba94164 100644 --- a/datacatalog/cloud-client/system-test/createEntryGroup.test.js +++ b/datacatalog/cloud-client/system-test/createEntryGroup.test.js @@ -16,9 +16,9 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); const cwd = path.join(__dirname, '..'); +const {exec} = require('child_process'); const projectId = process.env.GCLOUD_PROJECT; // Use unique id to avoid conflicts between concurrent test runs @@ -28,16 +28,28 @@ const location = 'us-central1'; const {DataCatalogClient} = require('@google-cloud/datacatalog').v1beta1; const datacatalog = new DataCatalogClient(); -before(tools.checkCredentials); +before(() => { + assert( + process.env.GCLOUD_PROJECT, + `Must set GCLOUD_PROJECT environment variable!` + ); + assert( + process.env.GOOGLE_APPLICATION_CREDENTIALS, + `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` + ); +}); describe('createEntryGroup', () => { - it('should create a entry group', async () => { - const output = await tools.runAsync( + it('should create a entry group', done => { + const expectedName = `projects/${projectId}/locations/${location}/entryGroups/${entryGroupId}`; + exec( `node createEntryGroup.js ${projectId} ${entryGroupId}`, - cwd + {cwd}, + (err, stdout) => { + assert.ok(stdout.includes(expectedName)); + done(); + } ); - const expectedName = `projects/${projectId}/locations/${location}/entryGroups/${entryGroupId}`; - assert.ok(output.includes(expectedName)); }); after(async () => { diff --git a/datacatalog/cloud-client/system-test/createFilesetEntry.test.js b/datacatalog/cloud-client/system-test/createFilesetEntry.test.js index 5a2a714b28..b5721e90ba 100644 --- a/datacatalog/cloud-client/system-test/createFilesetEntry.test.js +++ b/datacatalog/cloud-client/system-test/createFilesetEntry.test.js @@ -16,9 +16,9 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const uuid = require('uuid'); const cwd = path.join(__dirname, '..'); +const {exec} = require('child_process'); const projectId = process.env.GCLOUD_PROJECT; // Use unique id to avoid conflicts between concurrent test runs @@ -29,24 +29,33 @@ const location = 'us-central1'; const {DataCatalogClient} = require('@google-cloud/datacatalog').v1beta1; const datacatalog = new DataCatalogClient(); -before(tools.checkCredentials); +before(() => { + assert( + process.env.GCLOUD_PROJECT, + `Must set GCLOUD_PROJECT environment variable!` + ); + assert( + process.env.GOOGLE_APPLICATION_CREDENTIALS, + `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` + ); +}); describe('createFilesetEntry', () => { - before(async () => { + before(done => { // Must create entryGroup before creating entry - await tools.runAsync( - `node createEntryGroup.js ${projectId} ${entryGroupId}`, - cwd - ); + exec(`node createEntryGroup.js ${projectId} ${entryGroupId}`, {cwd}, done); }); - it('should create a fileset entry', async () => { - const output = await tools.runAsync( + it('should create a fileset entry', done => { + const expectedLinkedResource = `//datacatalog.googleapis.com/projects/${projectId}/locations/${location}/entryGroups/${entryGroupId}/entries/${entryId}`; + exec( `node createFilesetEntry.js ${projectId} ${entryGroupId} ${entryId}`, - cwd + {cwd}, + (err, stdout) => { + assert.ok(stdout.includes(expectedLinkedResource)); + done(); + } ); - const expectedLinkedResource = `//datacatalog.googleapis.com/projects/${projectId}/locations/${location}/entryGroups/${entryGroupId}/entries/${entryId}`; - assert.ok(output.includes(expectedLinkedResource)); }); after(async () => { diff --git a/datacatalog/cloud-client/system-test/lookupEntry.test.js b/datacatalog/cloud-client/system-test/lookupEntry.test.js index be1c7970f8..42f7c7fd0c 100644 --- a/datacatalog/cloud-client/system-test/lookupEntry.test.js +++ b/datacatalog/cloud-client/system-test/lookupEntry.test.js @@ -16,20 +16,32 @@ const path = require('path'); const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); const cwd = path.join(__dirname, '..'); +const {exec} = require('child_process'); -before(tools.checkCredentials); +before(() => { + assert( + process.env.GCLOUD_PROJECT, + `Must set GCLOUD_PROJECT environment variable!` + ); + assert( + process.env.GOOGLE_APPLICATION_CREDENTIALS, + `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` + ); +}); describe('lookupEntry lookup', () => { - it('should lookup a dataset entry', async () => { + it('should lookup a dataset entry', done => { const projectId = 'bigquery-public-data'; const datasetId = 'new_york_taxi_trips'; - const output = await tools.runAsync( + const expectedLinkedResource = `//bigquery.googleapis.com/projects/${projectId}/datasets/${datasetId}`; + exec( `node lookupEntry.js ${projectId} ${datasetId}`, - cwd + {cwd}, + (err, stdout) => { + assert.ok(stdout.includes(expectedLinkedResource)); + done(); + } ); - const expectedLinkedResource = `//bigquery.googleapis.com/projects/${projectId}/datasets/${datasetId}`; - assert.ok(output.includes(expectedLinkedResource)); }); }); diff --git a/datastore/functions/package.json b/datastore/functions/package.json index 235e9e11e9..096bc4b9db 100644 --- a/datastore/functions/package.json +++ b/datastore/functions/package.json @@ -27,9 +27,5 @@ "requestretry": "^4.0.0", "sinon": "^7.2.7", "uuid": "^3.3.2" - }, - "cloud-repo-tools": { - "requiresKeyFile": true, - "requiresProjectId": true } } diff --git a/storage-transfer/package.json b/storage-transfer/package.json index 6f2fb1f445..1c5870d4f0 100644 --- a/storage-transfer/package.json +++ b/storage-transfer/package.json @@ -14,7 +14,7 @@ "scripts": { "unit-test": "mocha test/*.test.js --timeout=10000", "system-test": "mocha system-test/*.test.js --timeout=10000", - "test": "repo-tools test install --cmd=npm -- run unit-test && repo-tools test install --cmd=npm -- run system-test" + "test": "npm run unit-test && npm run system-test" }, "dependencies": { "googleapis": "^45.0.0", @@ -23,24 +23,10 @@ }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.3.0", + "@google-cloud/storage": "^4.0.0", "mocha": "^6.0.0", "proxyquire": "^2.1.0", "sinon": "^7.2.7", - "@google-cloud/storage": "^4.0.0", "uuid": "^3.3.2" - }, - "cloud-repo-tools": { - "requiresKeyFile": true, - "requiresProjectId": true, - "product": "storage", - "samples": [ - { - "id": "transfer", - "name": "Storage Transfer API", - "file": "transfer.js", - "docs_link": "https://cloud.google.com/storage/transfer", - "usage": "node transfer.js --help" - } - ] } } diff --git a/storage-transfer/system-test/transfer.test.js b/storage-transfer/system-test/transfer.test.js index 9d344bd007..c2c4816424 100644 --- a/storage-transfer/system-test/transfer.test.js +++ b/storage-transfer/system-test/transfer.test.js @@ -33,7 +33,15 @@ const description = 'this is a test'; const status = 'DISABLED'; before(async () => { - tools.checkCredentials(); + assert( + process.env.GCLOUD_PROJECT, + `Must set GCLOUD_PROJECT environment variable!` + ); + assert( + process.env.GOOGLE_APPLICATION_CREDENTIALS, + `Must set GOOGLE_APPLICATION_CREDENTIALS environment variable!` + ); + tools.stubConsole(); const bucketOptions = {