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

Update cloud-sql/postgres sample #1553

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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'));
});