Skip to content

Commit 666e3ea

Browse files
authored
Update cloud-sql/postgres sample (#1553)
Update Node version to 10 for GAE Standard. Delete repo-tools. Clean up package.json
1 parent de32e42 commit 666e3ea

File tree

4 files changed

+19
-44
lines changed

4 files changed

+19
-44
lines changed

cloud-sql/postgres/knex/.cloud-repo-tools.json

-25
This file was deleted.

cloud-sql/postgres/knex/app.standard.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
runtime: nodejs8
14+
runtime: nodejs10
1515

1616
# The following env variables may contain sensitive information that grants
1717
# anyone access to your database. Do not add this file to your source control.

cloud-sql/postgres/knex/package.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
1111
},
1212
"engines": {
13-
"node": ">=8.0.0"
13+
"node": ">=10.0.0"
1414
},
1515
"scripts": {
16-
"unit-test": "mocha test/*.test.js --timeout=60000 --exit",
1716
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -dir=/cloudsql -instances=$CLOUD_SQL_INSTANCE_NAME &",
18-
"system-test": "repo-tools test app -- server.js",
19-
"system-test-proxy": "npm run start-proxy; npm run system-test",
20-
"all-test": "npm run unit-test && npm run system-test",
21-
"test": "repo-tools test run --cmd npm -- run all-test"
17+
"test": "mocha test/*.test.js --timeout=60000 --exit"
2218
},
2319
"dependencies": {
2420
"@google-cloud/logging-winston": "^3.0.0",
@@ -31,7 +27,6 @@
3127
"yargs": "^15.0.0"
3228
},
3329
"devDependencies": {
34-
"@google-cloud/nodejs-repo-tools": "3.3.0",
3530
"mocha": "^6.0.0",
3631
"supertest": "^4.0.0"
3732
}

cloud-sql/postgres/knex/test/createTable.test.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
const assert = require('assert');
1818
const path = require('path');
1919
const Knex = require('knex');
20-
const tools = require('@google-cloud/nodejs-repo-tools');
20+
const {exec} = require('child_process');
2121

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

@@ -41,20 +41,25 @@ before(async () => {
4141
}
4242
});
4343

44-
it('should create a table', async () => {
45-
const output = await tools.runAsync(
44+
it('should create a table', done => {
45+
exec(
4646
`node createTable.js ${DB_USER} ${DB_PASS} ${DB_NAME} ${CONNECTION_NAME}`,
47-
cwd
47+
{cwd},
48+
(err, stdout) => {
49+
assert.ok(stdout.includes(`Successfully created 'votes' table.`));
50+
done();
51+
}
4852
);
49-
assert.ok(output.includes(`Successfully created 'votes' table.`));
5053
});
5154

52-
it('should handle existing tables', async () => {
53-
const {stderr} = await tools.runAsyncWithIO(
55+
it('should handle existing tables', done => {
56+
exec(
5457
`node createTable.js ${DB_USER} ${DB_PASS} ${DB_NAME} ${CONNECTION_NAME}`,
55-
cwd
58+
{cwd},
59+
(err, stdout, stderr) => {
60+
assert.ok(stderr.includes("Failed to create 'votes' table:"));
61+
assert.ok(stderr.includes('already exists'));
62+
done();
63+
}
5664
);
57-
58-
assert.ok(stderr.includes("Failed to create 'votes' table:"));
59-
assert.ok(stderr.includes('already exists'));
6065
});

0 commit comments

Comments
 (0)