Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove repo-tools from several samples #1554

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions cloud-sql/postgres/knex/.cloud-repo-tools.json

This file was deleted.

2 changes: 1 addition & 1 deletion cloud-sql/postgres/knex/app.standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

runtime: nodejs8
runtime: nodejs10

# The following env variables may contain sensitive information that grants
# anyone access to your database. Do not add this file to your source control.
Expand Down
9 changes: 2 additions & 7 deletions cloud-sql/postgres/knex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">=8.0.0"
"node": ">=10.0.0"
},
"scripts": {
"unit-test": "mocha test/*.test.js --timeout=60000 --exit",
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -dir=/cloudsql -instances=$CLOUD_SQL_INSTANCE_NAME &",
"system-test": "repo-tools test app -- server.js",
"system-test-proxy": "npm run start-proxy; npm run system-test",
"all-test": "npm run unit-test && npm run system-test",
"test": "repo-tools test run --cmd npm -- run all-test"
"test": "mocha test/*.test.js --timeout=60000 --exit"
},
"dependencies": {
"@google-cloud/logging-winston": "^3.0.0",
Expand All @@ -31,7 +27,6 @@
"yargs": "^15.0.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "3.3.0",
"mocha": "^6.0.0",
"supertest": "^4.0.0"
}
Expand Down
27 changes: 16 additions & 11 deletions cloud-sql/postgres/knex/test/createTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const assert = require('assert');
const path = require('path');
const Knex = require('knex');
const tools = require('@google-cloud/nodejs-repo-tools');
const {exec} = require('child_process');

const cwd = path.join(__dirname, '..');

Expand All @@ -41,20 +41,25 @@ before(async () => {
}
});

it('should create a table', async () => {
const output = await tools.runAsync(
it('should create a table', done => {
exec(
`node createTable.js ${DB_USER} ${DB_PASS} ${DB_NAME} ${CONNECTION_NAME}`,
cwd
{cwd},
(err, stdout) => {
assert.ok(stdout.includes(`Successfully created 'votes' table.`));
done();
}
);
assert.ok(output.includes(`Successfully created 'votes' table.`));
});

it('should handle existing tables', async () => {
const {stderr} = await tools.runAsyncWithIO(
it('should handle existing tables', done => {
exec(
`node createTable.js ${DB_USER} ${DB_PASS} ${DB_NAME} ${CONNECTION_NAME}`,
cwd
{cwd},
(err, stdout, stderr) => {
assert.ok(stderr.includes("Failed to create 'votes' table:"));
assert.ok(stderr.includes('already exists'));
done();
}
);

assert.ok(stderr.includes("Failed to create 'votes' table:"));
assert.ok(stderr.includes('already exists'));
});
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