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

refactor(functions/sql): ava to mocha #1240

Merged
merged 4 commits into from
Apr 4, 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
6 changes: 3 additions & 3 deletions functions/sql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"start-proxy-pg": "cloud_sql_proxy -instances=$INSTANCE_CONNECTION_NAME-pg=tcp:5432 &",
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && npm run start-proxy-pg && npm run start-proxy-mysql || exit 0",
"kill-proxy": "killall cloud_sql_proxy",
"ava": "ava -T 20s --verbose test/*.test.js",
"test": "npm run start-proxy && npm run ava && npm run kill-proxy"
"mocha": "mocha test/*.test.js --timeout=20000",
"test": "npm run start-proxy && npm run mocha && npm run kill-proxy"
},
"dependencies": {
"mysql": "^2.16.0",
"pg": "^7.4.3"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"ava": "^0.25.0",
"mocha": "^6.0.0",
"proxyquire": "^2.1.0",
"sinon": "^7.3.0"
},
Expand Down
18 changes: 9 additions & 9 deletions functions/sql/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'use strict';

const sinon = require(`sinon`);
const test = require(`ava`);
const assert = require(`assert`);
const proxyquire = require(`proxyquire`);

const INSTANCE_PREFIX = `nodejs-docs-samples:us-central1:integration-tests-instance`;
Expand All @@ -29,7 +29,7 @@ const getProgram = env => {
});
};

test(`should query MySQL`, async t => {
it('should query MySQL', async () => {
const program = getProgram({
INSTANCE_CONNECTION_NAME: `${INSTANCE_PREFIX}-mysql`,
SQL_USER: process.env.MYSQL_USER,
Expand All @@ -49,14 +49,14 @@ test(`should query MySQL`, async t => {
setTimeout(resolve, 1500);
});

t.false(resMock.status.called);
t.true(resMock.send.calledOnce);
assert.strictEqual(resMock.status.called, false);
assert.ok(resMock.send.calledOnce);

const response = resMock.send.firstCall.args[0];
t.regex(response, /\d{4}-\d{1,2}-\d{1,2}/);
assert.ok(new RegExp(/\d{4}-\d{1,2}-\d{1,2}/).test(response.message));
});

test(`should query Postgres`, async t => {
it('should query Postgres', async () => {
const program = getProgram({
INSTANCE_CONNECTION_NAME: `${INSTANCE_PREFIX}-pg`,
SQL_USER: process.env.POSTGRES_USER,
Expand All @@ -76,9 +76,9 @@ test(`should query Postgres`, async t => {
setTimeout(resolve, 1500);
});

t.false(resMock.status.called);
t.true(resMock.send.calledOnce);
assert.strictEqual(resMock.status.called, false);
assert.ok(resMock.send.calledOnce);

const response = resMock.send.firstCall.args[0];
t.regex(response, /\d{4}-\d{1,2}-\d{1,2}/);
assert.ok(new RegExp(/\d{4}-\d{1,2}-\d{1,2}/).test(response.message));
});