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

Pubsub tests #164

Merged
merged 1 commit into from
Aug 10, 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
2 changes: 1 addition & 1 deletion bigquery/system-test/dataset_size.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('bigquery:dataset_size', function () {
'bigquery-public-data',
'hacker_news',
function (err, size) {
assert(!err);
assert.ifError(err);
assert.equal(typeof size, 'string');
assert(size.indexOf(' GB') === size.length - 3);
done();
Expand Down
2 changes: 1 addition & 1 deletion bigquery/system-test/getting_started.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('bigquery:getting_started', function () {
it('should run a query', function (done) {
gettingStartedExample.main(
function (err, rows) {
assert(!err);
assert.ifError(err);
assert(Array.isArray(rows));
assert.equal(rows.length, 10);
done();
Expand Down
2 changes: 1 addition & 1 deletion bigquery/system-test/load_data_from_csv.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('bigquery:load_data_from_csv', function () {
done(err);
});
} else {
assert(!err);
assert.ifError(err);
// metadata
assert.equal(results[1].status.state, 'DONE');
done();
Expand Down
2 changes: 1 addition & 1 deletion bigquery/system-test/load_data_from_gcs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('bigquery:load_data_from_gcs', function () {
done(err);
});
} else {
assert(!err);
assert.ifError(err);
// metadata
assert.equal(results[1].status.state, 'DONE');
done();
Expand Down
2 changes: 1 addition & 1 deletion computeengine/system-test/vms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var vmsExample = require('../vms');
describe('computeengine:vms', function () {
it('should retrieve vms', function (done) {
vmsExample.main(function (err, result) {
assert(!err);
assert.ifError(err);
assert(result);
assert(Array.isArray(result));
done();
Expand Down
2 changes: 1 addition & 1 deletion computeengine/system-test/vms_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var vmsExample = require('../vms_api');
describe('computeengine:vms_api', function () {
it('should retrieve vms', function (done) {
vmsExample.main(function (err, result) {
assert(!err);
assert.ifError(err);
assert(result);
done();
});
Expand Down
4 changes: 2 additions & 2 deletions datastore/system-test/concepts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('datastore:concepts', function () {
it('performs a projection query', function (done) {
entity.testProperties(function (err, tasks) {
console.log(err, tasks);
assert(!err);
assert.ifError(err);
setTimeout(function () {
query.testRunQueryProjection(done);
}, 1000);
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('datastore:concepts', function () {

it.skip('allows manual pagination through results', function (done) {
entity.testBatchUpsert(function (err) {
assert(!err);
assert.ifError(err);
setTimeout(function () {
query.testCursorPaging(done);
}, 1000);
Expand Down
6 changes: 3 additions & 3 deletions datastore/system-test/tasks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('datastore:tasks', function () {

it('should mark a task as done', function (done) {
getTaskId(function (err, taskId) {
assert(!err);
assert.ifError(err);
tasks.updateEntity(taskId, done);
});
});
Expand All @@ -43,14 +43,14 @@ describe('datastore:tasks', function () {

it('should delete a task', function (done) {
getTaskId(function (err, taskId) {
assert(!err);
assert.ifError(err);
tasks.deleteEntity(taskId, done);
});
});

it('should format tasks', function (done) {
tasks.retrieveEntities(function (err, _tasks) {
assert(!err);
assert.ifError(err);
assert.doesNotThrow(function () {
tasks.formatTasks(_tasks);
});
Expand Down
6 changes: 3 additions & 3 deletions language/system-test/analyze.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('language:analyze', function () {
'sentiment',
'This gazinga pin is bad and it should feel bad',
function (err, result) {
assert(!err);
assert.ifError(err);
assert(result);
assert(result.documentSentiment);
assert(result.documentSentiment.polarity < 0);
Expand All @@ -34,7 +34,7 @@ describe('language:analyze', function () {
'entities',
'Mark Twain is the author of a book called Tom Sawyer',
function (err, result) {
assert(!err);
assert.ifError(err);
assert(result);
assert(result.entities && result.entities.length);
assert(result.entities[0].name === 'Mark Twain');
Expand All @@ -51,7 +51,7 @@ describe('language:analyze', function () {
'buy some better butter - better than this bitter butter - it will ' +
'make my batter better."',
function (err, result) {
assert(!err);
assert.ifError(err);
assert(result);
assert(result.sentences && result.sentences.length);
assert(result.tokens && result.tokens.length > 5);
Expand Down
2 changes: 1 addition & 1 deletion logging/system-test/export.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var exportExample = require('../export');
describe('logging:export', function () {
it('should list sinks', function (done) {
exportExample.main(function (err, sinks) {
assert(!err);
assert.ifError(err);
assert(sinks, 'should have received sinks');
assert(Array.isArray(sinks), 'sinks should be an array');
done();
Expand Down
2 changes: 1 addition & 1 deletion logging/system-test/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var listExample = require('../list');
describe('logging:list', function () {
it('should list entries', function (done) {
listExample.main(undefined, function (err, entries, nextQuery, apiResponse) {
assert(!err);
assert.ifError(err);
assert(entries, 'should have received entries');
assert(Array.isArray(entries), 'entries should be an array');
assert(nextQuery, 'should have received nextQuery');
Expand Down
2 changes: 1 addition & 1 deletion logging/system-test/write.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('logging:write', function () {
if (err && err.code === 404) {
return done();
}
assert(!err);
assert.ifError(err);
assert(results.length === 2, 'should have two results');
done();
});
Expand Down
4 changes: 2 additions & 2 deletions monitoring/create_custom_metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ exports.main = function (projectId, name, cb) {
function (cb) {
setTimeout(function () {
customMetrics.writeTimeSeriesForCustomMetric(authClient, cb);
}, 5000);
}, 10000);
},
function (cb) {
setTimeout(function () {
customMetrics.listTimeSeries(authClient, cb);
}, 5000);
}, 10000);
},
function (cb) {
customMetrics.deleteMetric(authClient, cb);
Expand Down
5 changes: 1 addition & 4 deletions monitoring/system-test/create_custom_metric.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ describe('monitoring:create_custom_metric', function () {
process.env.GCLOUD_PROJECT,
Math.random().toString(36).substring(7),
function (err, results) {
assert(!err);
// console.log('---------------------------------------------');
// console.log(JSON.stringify(results, null, 2));
// console.log('---------------------------------------------');
assert.ifError(err);
assert(results.length === 4);
// Result of creating metric
assert(typeof results[0].name === 'string');
Expand Down
2 changes: 1 addition & 1 deletion monitoring/system-test/list_resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('monitoring:list_resources', function () {
listResourcesExample.main(
process.env.GCLOUD_PROJECT,
function (err, results) {
assert(!err);
assert.ifError(err);
assert(results.length === 3);
// Monitored resources
assert(Array.isArray(results[0].resourceDescriptors));
Expand Down
2 changes: 1 addition & 1 deletion prediction/system-test/hostedmodels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var hostedmodels = require('../../prediction/hostedmodels');
describe('prediction:hostedmodels', function () {
it('should predict', function (done) {
hostedmodels.main('good night', function (err, result) {
assert(!err);
assert.ifError(err);
assert(result);
assert(console.log.calledWith('Sentiment for "good night": positive'));
done();
Expand Down
87 changes: 77 additions & 10 deletions pubsub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ allows you to send and receive messages between independent applications.

* [Setup](#setup)
* [Samples](#samples)
* [Subscription](#subscription)
* [Topics](#topics)
* [Subscriptions](#subscriptions)
* [IAM](#iam)

## Setup
Expand All @@ -26,24 +27,90 @@ allows you to send and receive messages between independent applications.

## Samples

### Subscription
### Topics

View the [documentation][subscription_docs] or the [source code][subscription_code].
View the [documentation][topics_docs] or the [source code][topics_code].

__Run the sample:__
__Usage:__ `node topics --help`

node subscription
```
Usage: node topics COMMAND [ARGS...]

[subscription_docs]: https://cloud.google.com/pubsub/subscriber
[subscription_code]: subscription.js
Commands:

create TOPIC_NAME
delete TOPIC_NAME
publish TOPIC_NAME MESSAGE
list

Examples:

node topics create my-topic
node topics list
node topics publish my-topic '{"data":"Hello world!"}'
node topics delete my-topic
```

[topics_docs]: https://cloud.google.com/pubsub/publisher
[topics_code]: topics.js

### Subscriptions

View the [documentation][subscriptions_docs] or the [source code][subscriptions_code].

__Usage:__ `node subscriptions --help`

```
Usage: node subscriptions COMMAND [ARGS...]

Commands:

create TOPIC_NAME SUBSCRIPTION_NAME
delete SUBSCRIPTION_NAME
pull SUBSCRIPTION_NAME
list [TOPIC_NAME]

Examples:

node subscriptions create my-topic my-subscription
node subscriptions delete my-subscription
node subscriptions pull my-subscription
node subscriptions list
node subscriptions list my-topic
```

[subscriptions_docs]: https://cloud.google.com/pubsub/subscriber
[subscriptions_code]: subscriptions.js

### IAM

View the [documentation][iam_docs] or the [source code][iam_code].

__Run the sample:__
__Usage:__ `node iam --help`

```
Usage: node iam RESOURCE COMMAND [ARGS...]

Resources:

topics
subscriptions

Commands:

get NAME
set NAME
test NAME

Examples:

node iam
node iam topics get my-topic
node iam topics set my-topic
node iam topics test my-topic
node iam subscriptions get my-subscription
node iam subscriptions set my-subscription
node iam subscriptions test my-subscription
```

[iam_docs]: https://cloud.google.com/pubsub/access_control
[iam_code]: subscription.js
[iam_code]: iam.js
Loading