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

chore: refactor cloudsql_postgresql test #1700

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
bd9e5dd
chore: refactor cloudsql_postgresql
sofisl Apr 1, 2020
7039b84
Merge branch 'master' into cloudSQLPOSTGRESTest
sofisl Apr 1, 2020
5e8395e
check: user, password and database env variables
sofisl Apr 10, 2020
5bf5db5
Merge branch 'master' into cloudSQLPOSTGRESTest
sofisl Apr 10, 2020
e6b13b0
fix: try killing child process
sofisl Apr 16, 2020
dd5039c
try
sofisl Apr 16, 2020
a755c79
try
sofisl Apr 16, 2020
f025e89
try
sofisl Apr 16, 2020
620bda9
try
sofisl Apr 16, 2020
7ac61b6
try
sofisl Apr 16, 2020
a58dd3a
npm: runfix
sofisl Apr 16, 2020
4db14a4
Merge branch 'master' into cloudSQLPOSTGRESTest
sofisl Apr 16, 2020
55ea26c
fix: remove repo-tools dependency
sofisl Apr 16, 2020
9de5955
Merge branch 'cloudSQLPOSTGRESTest' of github.com:sofisl/nodejs-docs-…
sofisl Apr 16, 2020
7c3b6cc
fix dependencies
sofisl Apr 16, 2020
ad7a245
chore(deps): update dependency puppeteer to v3 (#1719)
renovate-bot Apr 16, 2020
ad7cd89
chore:refactor memcached test (#1698)
sofisl Apr 16, 2020
2c26a14
healthcare API: update hl7v2 samples from v1beta1 to v1 (#1721)
noerog Apr 16, 2020
068b7fc
chore: refactor cloudsql_postgresql
sofisl Apr 1, 2020
3b5bb95
check: user, password and database env variables
sofisl Apr 10, 2020
40eb2dd
fix: try killing child process
sofisl Apr 16, 2020
5989d88
try
sofisl Apr 16, 2020
02f841c
try
sofisl Apr 16, 2020
ba98372
try
sofisl Apr 16, 2020
512a427
try
sofisl Apr 16, 2020
de47c04
try
sofisl Apr 16, 2020
d6718ec
npm: runfix
sofisl Apr 16, 2020
f4b3389
fix: remove repo-tools dependency
sofisl Apr 16, 2020
8ce569e
fix dependencies
sofisl Apr 16, 2020
7c238f1
chore: refactor cloudsql_postgresql
sofisl Apr 1, 2020
79f0e58
check: user, password and database env variables
sofisl Apr 10, 2020
39fcc4c
fix: try killing child process
sofisl Apr 16, 2020
3a21368
try
sofisl Apr 16, 2020
b34f1b4
try
sofisl Apr 16, 2020
b4c2531
try
sofisl Apr 16, 2020
12f095f
try
sofisl Apr 16, 2020
43b6f9f
try
sofisl Apr 16, 2020
216f91e
npm: runfix
sofisl Apr 16, 2020
2604116
fix: remove repo-tools dependency
sofisl Apr 16, 2020
65427cf
fix dependencies
sofisl Apr 16, 2020
435f0f6
fix: rebase
sofisl Apr 16, 2020
8801322
chore: refactor cloudsql_postgresql
sofisl Apr 1, 2020
3837027
check: user, password and database env variables
sofisl Apr 10, 2020
5385fe3
fix: try killing child process
sofisl Apr 16, 2020
e599468
try
sofisl Apr 16, 2020
7723252
try
sofisl Apr 16, 2020
89673dc
try
sofisl Apr 16, 2020
3831f7c
try
sofisl Apr 16, 2020
b5048d1
npm: runfix
sofisl Apr 16, 2020
9bc4952
try
sofisl Apr 16, 2020
65e5f76
fix: remove repo-tools dependency
sofisl Apr 16, 2020
f53a2f2
fix dependencies
sofisl Apr 16, 2020
bbd831a
Merge branch 'cloudSQLPOSTGRESTest' of github.com:sofisl/nodejs-docs-…
sofisl Apr 16, 2020
a67c113
fix: rebase
sofisl Apr 16, 2020
5ee82f4
Merge branch 'cloudSQLPOSTGRESTest' of github.com:sofisl/nodejs-docs-…
sofisl Apr 16, 2020
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
1 change: 0 additions & 1 deletion appengine/cloudsql/test/createTables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const getSample = () => {
};

const stubConsole = function () {
/* eslint-disable no-console */
sinon.stub(console, `error`);
sinon.stub(console, `log`);
};
Expand Down
7 changes: 4 additions & 3 deletions appengine/cloudsql_postgresql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"node": ">=8.0.0"
},
"scripts": {
"unit-test": "mocha test/*.test.js --timeout=30000",
"unit-test": "mocha test/createTables.test.js --timeout=30000 && mocha test/server.test.js",
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -instances=$INSTANCE_CONNECTION_NAME=tcp:$SQL_PORT &",
"system-test": "repo-tools test app -- server.js",
"system-test": "mocha test/serverListening.test.js --exit",
"system-test-proxy": "npm run start-proxy; npm run system-test",
"all-test": "npm run unit-test && npm run system-test",
"test": "npm -- run all-test"
Expand All @@ -27,8 +27,9 @@
"prompt": "^1.0.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0",
"mocha": "^7.0.0",
"wait-port": "^0.2.7",
"chai": "^4.2.0",
"proxyquire": "^2.1.0",
"sinon": "^9.0.0",
"supertest": "^4.0.0"
Expand Down
2 changes: 0 additions & 2 deletions appengine/cloudsql_postgresql/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const insertVisit = (knex, visit) => {
* @param {object} knex The Knex connection object.
* @returns {Promise}
*/

const getVisits = async (knex) => {
const results = await knex
.select('timestamp', 'userIp')
Expand Down Expand Up @@ -99,7 +98,6 @@ app.get('/', async (req, res, next) => {

// Query the last 10 visits from the database.
const visits = await getVisits(knex);

res
.status(200)
.set('Content-Type', 'text/plain')
Expand Down
1 change: 0 additions & 1 deletion appengine/cloudsql_postgresql/test/createTables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ describe('gae_flex_postgres_create_tables', () => {
knex: sample.mocks.Knex,
prompt: sample.mocks.prompt,
});

await new Promise((r) => setTimeout(r, 10));
assert.ok(console.error.calledOnce);
assert.ok(
Expand Down
15 changes: 15 additions & 0 deletions appengine/cloudsql_postgresql/test/serverListening.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const waitPort = require('wait-port');
const {expect} = require('chai');
const PORT = process.env.PORT || 8080;
const childProcess = require('child_process');
const path = require('path');
const appPath = path.join(__dirname, '../server.js');

describe('server listening', () => {
it('should be listening', async () => {
const child = childProcess.exec(`node ${appPath}`);
const isOpen = await waitPort({port: PORT});
expect(isOpen).to.be.true;
process.kill(child.pid, 'SIGTERM');
});
});
4 changes: 3 additions & 1 deletion appengine/memcached/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ app.get('/', async (req, res, next) => {
});

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
const server = app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});

module.exports = server;
6 changes: 4 additions & 2 deletions appengine/memcached/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
},
"scripts": {
"start": "node app.js",
"test": "repo-tools test app"
"test": "mocha --exit test/*.test.js"
},
"dependencies": {
"express": "^4.16.4",
"memjs": "^1.2.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.3.0"
"chai": "^4.2.0",
"mocha": "^7.1.1",
"wait-port": "^0.2.7"
}
}
13 changes: 13 additions & 0 deletions appengine/memcached/test/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const waitPort = require('wait-port');
const {expect} = require('chai');

const PORT = process.env.PORT || 8080;

describe('server listening', () => {
it('should be listening', async () => {
const server = require('../app.js');
const isOpen = await waitPort({port: PORT});
expect(isOpen).to.be.true;
server.close();
});
});
2 changes: 1 addition & 1 deletion appengine/websockets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.0.0",
"mocha": "^7.0.0",
"puppeteer": "^2.0.0"
"puppeteer": "^3.0.0"
},
"cloud-repo-tools": {
"test": {
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/createHl7v2Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_create_hl7v2_message]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');
const fs = require('fs');
const util = require('util');
const readFile = util.promisify(fs.readFile);
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/createHl7v2Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_create_hl7v2_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const createHl7v2Store = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/deleteHl7v2Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_delete_hl7v2_message]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const deleteHl7v2Message = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/deleteHl7v2Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_delete_hl7v2_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const deleteHl7v2Store = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/getHl7v2Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_get_hl7v2_message]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getHl7v2Message = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/getHl7v2Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_get_hl7v2_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getHl7v2Store = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/getHl7v2StoreIamPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_hl7v2_store_get_iam_policy]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getHl7v2StoreIamPolicy = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/ingestHl7v2Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_ingest_hl7v2_message]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');
const fs = require('fs');
const util = require('util');
const readFile = util.promisify(fs.readFile);
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/listHl7v2Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_list_hl7v2_messages]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const listHl7v2Messages = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/listHl7v2Stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const main = (
) => {
// [START healthcare_list_hl7v2_stores]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const listHl7v2Stores = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"mocha": "^7.0.0"
},
"dependencies": {
"googleapis": "^48.0.0",
"googleapis": "^49.0.0",
"uuid": "^7.0.0",
"yargs": "^15.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/patchHl7v2Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const main = (
) => {
// [START healthcare_patch_hl7v2_message]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const patchHl7v2Message = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/patchHl7v2Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_patch_hl7v2_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const patchHl7v2Store = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/hl7v2/setHl7v2StoreIamPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_hl7v2_store_set_iam_policy]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const setHl7v2StoreIamPolicy = async () => {
const auth = await google.auth.getClient({
Expand Down