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(opencensus): ava to mocha #1244

Merged
merged 3 commits into from
Apr 10, 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
4 changes: 2 additions & 2 deletions opencensus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
},
"scripts": {
"start": "node metrics-quickstart.js",
"test": "repo-tools test run --cmd ava -- -T 65s --verbose system-test/*.test.js"
"test": "repo-tools test run --cmd mocha -- system-test/*.test.js --timeout=5000"
},
"dependencies": {
"@opencensus/core": "^0.0.9",
"@opencensus/exporter-stackdriver": "^0.0.9"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"ava": "^0.25.0"
"mocha": "^6.0.0"
},
"cloud-repo-tools": {
"requiresKeyFile": true,
Expand Down
22 changes: 14 additions & 8 deletions opencensus/system-test/metrics-quickstart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@

'use strict';

const test = require(`ava`);
const tools = require(`@google-cloud/nodejs-repo-tools`);
const assert = require('assert');
const tools = require('@google-cloud/nodejs-repo-tools');

test('Should throw an error without projectId', async t => {
it('Should throw an error without projectId', done => {
process.env.GOOGLE_PROJECT_ID = '';
const error = new Error(`Unable to proceed without a Project ID`);
await t.throws(tools.runAsync(`node metrics-quickstart.js`), Error, error);
tools.runAsync('node metrics-quickstart.js').then(
() => {},
err => {
assert.ok(err.message.includes(error.message));
done();
}
);
});

test('Should capture stats data and export it to backend', async t => {
it('Should capture stats data and export it to backend', async () => {
process.env.GOOGLE_PROJECT_ID = 'fake-id';
process.env.KUBERNETES_SERVICE_HOST = 'localhost';
const output = await tools.runAsync(`node metrics-quickstart.js`);
t.regex(output, new RegExp(`Latency *:*`));
t.regex(output, /Done recording metrics./);
const output = await tools.runAsync('node metrics-quickstart.js');
assert.ok(new RegExp('Latency *:*').test(output));
assert.ok(new RegExp('Done recording metrics.').test(output));
});