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

Improve test coverage. #139

Merged
merged 3 commits into from
Jun 23, 2016
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
]
},
"scripts": {
"ava": "ava --match='!*: dependencies should install*' --timeout=1m --fail-fast --concurrency=5",
"ava": "ava --match='!*: dependencies should install*' --timeout=2m --fail-fast --concurrency=5",
"ava:deps": "npm run deps_appengine && npm run ava",
"cover": "npm run deps_appengine && nyc ava --match='!*: dependencies should install*'",
"cover": "npm run deps_appengine && nyc ava --match='!*: dependencies should install*' --timeout=2m --fail-fast --concurrency=5 --cache",
"deps_appengine": "ava --match='*: dependencies should install*'",
"deps_bigquery": "cd bigquery; npm i; cd ../",
"deps_computeengine": "cd computeengine; npm i; cd ../",
Expand Down
4 changes: 4 additions & 0 deletions pubsub/iam.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ function testSubscriptionPermissionsExample (subscriptionName, callback) {
}
// [END test_subscription_permissions]

exports.getTopicPolicyExample = getTopicPolicyExample;
exports.getSubscriptionPolicyExample = getSubscriptionPolicyExample;
exports.setTopicPolicyExample = setTopicPolicyExample;
exports.setSubscriptionPolicyExample = setSubscriptionPolicyExample;
exports.testTopicPermissionsExample = testTopicPermissionsExample;
exports.testSubscriptionPermissionsExample = testSubscriptionPermissionsExample;

// Run the examples
exports.main = function (cb) {
Expand Down
4 changes: 4 additions & 0 deletions pubsub/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ exports.createTopicExample = createTopicExample;
exports.deleteTopicExample = deleteTopicExample;
exports.subscribeExample = subscribeExample;
exports.deleteSubscriptionExample = deleteSubscriptionExample;
exports.publishExample = publishExample;
exports.getAllTopicsExample = getAllTopicsExample;
exports.getAllSubscriptionsExample = getAllSubscriptionsExample;
exports.subscribeExample = subscribeExample;
exports.pubsub = pubsub;
exports.main = function (cb) {
var topicName = 'messageCenter';
Expand Down
6 changes: 3 additions & 3 deletions test/appengine/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ sampleTests.forEach(function (sample) {
sample.env.SERVER_URL = sample.env.SERVER_URL + port + '/parse';
}
port++;
test.cb(sample.dir + ': dependencies should install', function (t) {
test.cb.serial(sample.dir + ': dependencies should install', function (t) {
testInstallation(sample, t.end);
});

Expand All @@ -330,13 +330,13 @@ sampleTests.forEach(function (sample) {
return;
}

test.cb(sample.dir + ' should return 200 and Hello World', function (t) {
test.cb.serial(sample.dir + ' should return 200 and Hello World', function (t) {
testLocalApp(sample, t.end);
});
});

if (process.env.TRAVIS && process.env.DEPLOY_TESTS) {
test.cb('should deploy all samples', function (t) {
test.cb.serial('should deploy all samples', function (t) {
// 30 minutes because deployments are slow
this.timeout(30 * 60 * 1000);

Expand Down
2 changes: 1 addition & 1 deletion test/bigquery/dataset_size.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var datasetSizeExample = require('../../bigquery/dataset_size');

test.cb('should return the size of a dataset', function (t) {
test.cb.serial('should return the size of a dataset', function (t) {
datasetSizeExample.main(
'bigquery-public-data',
'hacker_news',
Expand Down
2 changes: 1 addition & 1 deletion test/bigquery/getting_started.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var gettingStartedExample = require('../../bigquery/getting_started');

test.cb('should run a query', function (t) {
test.cb.serial('should run a query', function (t) {
gettingStartedExample.main(
function (err, rows) {
t.ifError(err);
Expand Down
2 changes: 1 addition & 1 deletion test/bigquery/load_data_from_csv.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var datasetId = 'nodejs_docs_samples';
var tableName = 'test_' + new Date().getTime() + '_' +
Math.floor(Math.random() * 10000);

test.cb('should load data from a csv file', function (t) {
test.cb.serial('should load data from a csv file', function (t) {
async.series([
function (cb) {
loadDataFromCsvExample.createTable(datasetId, tableName, cb);
Expand Down
2 changes: 1 addition & 1 deletion test/bigquery/load_data_from_gcs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var datasetId = 'nodejs_docs_samples';
var tableName = 'test_' + new Date().getTime() + '_' +
Math.floor(Math.random() * 10000);

test.cb('should load data from a csv file in a GCS bucket', function (t) {
test.cb.serial('should load data from a csv file in a GCS bucket', function (t) {
async.series([
function (cb) {
loadDataFromCsvExample.createTable(datasetId, tableName, cb);
Expand Down
2 changes: 1 addition & 1 deletion test/computeengine/mailjet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var proxyquire = require('proxyquire').noPreserveCache();
process.env.MAILJET_API_KEY = 'foo';
process.env.MAILJET_API_SECRET = 'bar';

test.cb('should send an email', function (t) {
test.cb.serial('should send an email', function (t) {
proxyquire('../../computeengine/mailjet.js', {
nodemailer: {
createTransport: function (arg) {
Expand Down
2 changes: 1 addition & 1 deletion test/computeengine/sendgrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var test = require('ava');
var proxyquire = require('proxyquire').noPreserveCache();
process.env.SENDGRID_API_KEY = 'foo';

test.cb('should send an email', function (t) {
test.cb.serial('should send an email', function (t) {
proxyquire('../../computeengine/sendgrid.js', {
sendgrid: function (key) {
t.is(key, 'foo');
Expand Down
2 changes: 1 addition & 1 deletion test/computeengine/vms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var vmsExample = require('../../computeengine/vms');

test.cb('should retrieve vms', function (t) {
test.cb.serial('should retrieve vms', function (t) {
vmsExample.main(function (err, result) {
t.ifError(err);
t.truthy(result);
Expand Down
2 changes: 1 addition & 1 deletion test/computeengine/vms_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var vmsExample = require('../../computeengine/vms_api');

test.cb('should retrieve vms', function (t) {
test.cb.serial('should retrieve vms', function (t) {
vmsExample.main(function (err, result) {
t.ifError(err);
t.truthy(result);
Expand Down
2 changes: 1 addition & 1 deletion test/datastore/concepts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test.before(function () {
query = new Query(projectId);
});

test.after.cb(function (t) {
test.after.cb.serial(function (t) {
var datastore = transaction.datastore;
var query = datastore.createQuery('Task');

Expand Down
2 changes: 1 addition & 1 deletion test/datastore/tasks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var async = require('async');
var tasks = require('../../datastore/tasks.js');
var taskIds = [];

test.after.cb(function (t) {
test.after.cb.serial(function (t) {
async.parallel(taskIds.map(function (taskId) {
return function (cb) {
tasks.deleteEntity(taskId, cb);
Expand Down
2 changes: 1 addition & 1 deletion test/functions/background.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test('should throw an error', function (t) {
t.throws(function () {
backgroundSample.sample.helloSynchronous({
something: false
})
});
}, Error, 'Something was not true!');
});

Expand Down
2 changes: 1 addition & 1 deletion test/functions/gcs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test('Fails without a file', function (t) {
t.is(context.success.called, false);
});

test.cb('Reads the file line by line', function (t) {
test.cb.serial('Reads the file line by line', function (t) {
var expectedMsg = 'The file sample.txt has 114 words';
var data = {
bucket: 'bucket',
Expand Down
6 changes: 3 additions & 3 deletions test/functions/helloworld.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('helloworld:helloworld: should log a message', function (t) {
t.is(console.log.calledWith(expectedMsg), true);
});

test.cb('helloworld:helloGET: should print hello world', function (t) {
test.cb.serial('helloworld:helloGET: should print hello world', function (t) {
var expectedMsg = 'Hello World!';
helloworldSample.helloGET({}, {
send: function (message) {
Expand All @@ -52,7 +52,7 @@ test.cb('helloworld:helloGET: should print hello world', function (t) {
});
});

test.cb('helloworld:helloHttp: should print a name', function (t) {
test.cb.serial('helloworld:helloHttp: should print a name', function (t) {
var expectedMsg = 'Hello John!';
helloworldSample.helloHttp({
body: {
Expand All @@ -66,7 +66,7 @@ test.cb('helloworld:helloHttp: should print a name', function (t) {
});
});

test.cb('helloworld:helloHttp: should print hello world', function (t) {
test.cb.serial('helloworld:helloHttp: should print hello world', function (t) {
var expectedMsg = 'Hello World!';
helloworldSample.helloHttp({
body: {}
Expand Down
2 changes: 1 addition & 1 deletion test/functions/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var moduleSample = require('../../functions/module');

test.cb('should return a hello world message', function (t) {
test.cb.serial('should return a hello world message', function (t) {
moduleSample.helloworld({
success: function (result) {
t.is(result, 'Hello World!');
Expand Down
18 changes: 9 additions & 9 deletions test/functions/ocr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test('processImage fails without a name', function (t) {
t.is(console.error.called, true);
});

test.cb('processImage handles detectText error', function (t) {
test.cb.serial('processImage handles detectText error', function (t) {
var expectedMsg = 'error';
var context = {
success: t.fail,
Expand All @@ -156,7 +156,7 @@ test.cb('processImage handles detectText error', function (t) {
});
});

test.cb('processImage processes an image', function (t) {
test.cb.serial('processImage processes an image', function (t) {
var context = {
success: function () {
t.is(context.success.calledOnce, true);
Expand Down Expand Up @@ -227,7 +227,7 @@ test('translateText fails without a lang', function (t) {
t.is(console.error.called, true);
});

test.cb('translateText handles translation error', function (t) {
test.cb.serial('translateText handles translation error', function (t) {
var expectedMsg = 'error';
var context = {
success: t.fail,
Expand All @@ -252,7 +252,7 @@ test.cb('translateText handles translation error', function (t) {
});
});

test.cb('translateText handles get topic error', function (t) {
test.cb.serial('translateText handles get topic error', function (t) {
var expectedMsg = 'error';
var context = {
success: t.fail,
Expand All @@ -278,7 +278,7 @@ test.cb('translateText handles get topic error', function (t) {
});
});

test.cb('translateText handles publish error', function (t) {
test.cb.serial('translateText handles publish error', function (t) {
var expectedMsg = 'error';
var context = {
success: t.fail,
Expand All @@ -304,7 +304,7 @@ test.cb('translateText handles publish error', function (t) {
});
});

test.cb('translateText translates and publishes text', function (t) {
test.cb.serial('translateText translates and publishes text', function (t) {
var context = {
success: function () {
t.is(context.success.called, true);
Expand Down Expand Up @@ -371,7 +371,7 @@ test('saveResult fails without a lang', function (t) {
t.is(console.error.called, true);
});

test.cb('saveResult handles save error', function (t) {
test.cb.serial('saveResult handles save error', function (t) {
var expectedMsg = 'error';
var context = {
success: t.fail,
Expand All @@ -396,7 +396,7 @@ test.cb('saveResult handles save error', function (t) {
});
});

test.cb('saveResult translates and publishes text', function (t) {
test.cb.serial('saveResult translates and publishes text', function (t) {
var context = {
success: function () {
t.is(context.success.called, true);
Expand All @@ -418,7 +418,7 @@ test.cb('saveResult translates and publishes text', function (t) {
});
});

test.cb('saveResult translates and publishes text with dot in filename', function (t) {
test.cb.serial('saveResult translates and publishes text with dot in filename', function (t) {
var context = {
success: function () {
t.is(context.success.called, true);
Expand Down
2 changes: 1 addition & 1 deletion test/functions/uuid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var uuidSample = require('../../functions/uuid');

test.cb('should generate a uuid', function (t) {
test.cb.serial('should generate a uuid', function (t) {
uuidSample.uuid({
success: function (uuid) {
t.is(typeof uuid, 'string');
Expand Down
2 changes: 1 addition & 1 deletion test/logging/export.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var exportExample = require('../../logging/export');

test.cb('should list sinks', function (t) {
test.cb.serial('should list sinks', function (t) {
exportExample.main(function (err, sinks) {
t.ifError(err);
t.truthy(sinks, 'should have received sinks');
Expand Down
2 changes: 1 addition & 1 deletion test/logging/fluent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var test = require('ava');
var proxyquire = require('proxyquire').noPreserveCache();
var request = require('supertest');

test.cb('should log error', function (t) {
test.cb.serial('should log error', function (t) {
var loggerCalled = false;

var structuredLogger = {
Expand Down
2 changes: 1 addition & 1 deletion test/logging/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var listExample = require('../../logging/list');

test.cb('should list entries', function (t) {
test.cb.serial('should list entries', function (t) {
listExample.main(undefined, function (err, entries, nextQuery, apiResponse) {
t.ifError(err);
t.truthy(entries, 'should have received entries');
Expand Down
2 changes: 1 addition & 1 deletion test/logging/write.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var writeExample = require('../../logging/write');

test.cb('should write entries', function (t) {
test.cb.serial('should write entries', function (t) {
writeExample.main(function (err, results) {
if (err && err.code === 404) {
return t.end();
Expand Down
2 changes: 1 addition & 1 deletion test/monitoring/create_custom_metric.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getPointValue (timeSeries) {
return timeSeries.timeSeries[0].points[0].value.int64Value;
}

test.cb('should create and read back a custom metric', function (t) {
test.cb.serial('should create and read back a custom metric', function (t) {
customMetricsExample.main(
process.env.GCLOUD_PROJECT,
Math.random().toString(36).substring(7),
Expand Down
2 changes: 1 addition & 1 deletion test/monitoring/list_resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var listResourcesExample = require('../../monitoring/list_resources');

test.cb('should list a bunch of stuff', function (t) {
test.cb.serial('should list a bunch of stuff', function (t) {
listResourcesExample.main(
process.env.GCLOUD_PROJECT,
function (err, results) {
Expand Down
2 changes: 1 addition & 1 deletion test/prediction/hostedmodels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var test = require('ava');
var hostedmodels = require('../../prediction/hostedmodels');

test.cb('should predict', function (t) {
test.cb.serial('should predict', function (t) {
hostedmodels.main('good night', function (err, result) {
t.ifError(err);
t.truthy(result);
Expand Down
Loading