Skip to content

Commit

Permalink
Remove repo-tools from several samples
Browse files Browse the repository at this point in the history
  • Loading branch information
fhinkel committed Nov 27, 2019
1 parent 8219a20 commit a36b957
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 61 deletions.
1 change: 0 additions & 1 deletion cloud-tasks/function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 0 additions & 13 deletions datacatalog/cloud-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
}
}
26 changes: 19 additions & 7 deletions datacatalog/cloud-client/system-test/createEntryGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 () => {
Expand Down
33 changes: 21 additions & 12 deletions datacatalog/cloud-client/system-test/createFilesetEntry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 () => {
Expand Down
26 changes: 19 additions & 7 deletions datacatalog/cloud-client/system-test/lookupEntry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});
4 changes: 0 additions & 4 deletions datastore/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,5 @@
"requestretry": "^4.0.0",
"sinon": "^7.2.7",
"uuid": "^3.3.2"
},
"cloud-repo-tools": {
"requiresKeyFile": true,
"requiresProjectId": true
}
}
18 changes: 2 additions & 16 deletions storage-transfer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
]
}
}
10 changes: 9 additions & 1 deletion storage-transfer/system-test/transfer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit a36b957

Please sign in to comment.