Skip to content

Commit 7528e09

Browse files
add tests
1 parent 19e8e81 commit 7528e09

File tree

7 files changed

+57
-141
lines changed

7 files changed

+57
-141
lines changed

lib/datastore/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ var util = require('../common/util.js');
205205
* var query = datastore.createQuery('Contacts')
206206
* .limit(NUM_RESULTS_PER_PAGE);
207207
*
208-
* if (req.query.startCursor) {
209-
* query.start(req.query.startCursor);
208+
* if (req.query.nextPageCursor) {
209+
* query.start(req.query.nextPageCursor);
210210
* }
211211
*
212212
* datastore.runQuery(query, function(err, entities, info) {
@@ -222,7 +222,7 @@ var util = require('../common/util.js');
222222
* };
223223
*
224224
* if (info.moreResults !== 'NO_MORE_RESULTS') {
225-
* frontEndResponse.startCursor = info.endCursor;
225+
* frontEndResponse.nextPageCursor = info.endCursor;
226226
* }
227227
*
228228
* res.render('contacts', frontEndResponse);

lib/datastore/query.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,9 @@ Query.prototype.offset = function(n) {
296296
* - `MORE_RESULTS_AFTER_CURSOR`: There *may* be more results after the
297297
* specified end cursor.
298298
* - `NO_MORE_RESULTS`: There are no more results.
299-
* @param {object} callback.apiResponse - The full API response.
300299
*
301300
* @example
302-
* query.run(function(err, entities, info, apiResponse) {});
301+
* query.run(function(err, entities, info) {});
303302
*
304303
* //-
305304
* // If you omit the callback, you will get the matching entities in a readable
@@ -309,7 +308,6 @@ Query.prototype.offset = function(n) {
309308
* .on('error', console.error)
310309
* .on('data', function (entity) {})
311310
* .on('info', function(info) {})
312-
* .on('response', function(apiResponse) {})
313311
* .on('end', function() {
314312
* // All entities retrieved.
315313
* });

lib/datastore/request.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ DatastoreRequest.prototype.insert = function(entities, callback) {
392392
* - `MORE_RESULTS_AFTER_CURSOR`: There *may* be more results after the
393393
* specified end cursor.
394394
* - `NO_MORE_RESULTS`: There are no more results.
395-
* @param {object} callback.apiResponse - The full API response.
396395
*
397396
* @example
398397
* //-
@@ -401,7 +400,7 @@ DatastoreRequest.prototype.insert = function(entities, callback) {
401400
* //-
402401
* var query = datastore.createQuery('Lion');
403402
*
404-
* datastore.runQuery(query, function(err, entities, info, apiResponse) {});
403+
* datastore.runQuery(query, function(err, entities, info) {});
405404
*
406405
* //-
407406
* // Or, if you're using a transaction object.
@@ -420,7 +419,6 @@ DatastoreRequest.prototype.insert = function(entities, callback) {
420419
* .on('error', console.error)
421420
* .on('data', function (entity) {})
422421
* .on('info', function(info) {})
423-
* .on('response', function(apiResponse) {})
424422
* .on('end', function() {
425423
* // All entities retrieved.
426424
* });
@@ -453,21 +451,17 @@ DatastoreRequest.prototype.runQuery = function(query, options, callback) {
453451

454452
options = options || {};
455453

456-
var apiResponse;
457454
var info;
458455

459456
if (is.fn(callback)) {
460457
// Run this method in stream mode and send the results back to the callback.
461458
this.runQuery(query, options)
462459
.on('error', callback)
463-
.on('response', function(apiResponse_) {
464-
apiResponse = apiResponse_;
465-
})
466460
.on('info', function(info_) {
467461
info = info_;
468462
})
469463
.pipe(concat(function(results) {
470-
callback(null, results, info, apiResponse);
464+
callback(null, results, info);
471465
}));
472466
return;
473467
}
@@ -496,6 +490,8 @@ DatastoreRequest.prototype.runQuery = function(query, options, callback) {
496490
};
497491
}
498492

493+
this.request_(protoOpts, reqOpts, onResponse);
494+
499495
function onResponse(err, resp) {
500496
if (err) {
501497
stream.destroy(err);
@@ -523,7 +519,6 @@ DatastoreRequest.prototype.runQuery = function(query, options, callback) {
523519
}
524520

525521
if (resp.batch.moreResults !== 'NOT_FINISHED') {
526-
stream.emit('response', resp);
527522
stream.emit('info', info);
528523
stream.push(null);
529524
return;
@@ -546,8 +541,6 @@ DatastoreRequest.prototype.runQuery = function(query, options, callback) {
546541
});
547542
}
548543

549-
this.request_(protoOpts, reqOpts, onResponse);
550-
551544
return stream;
552545
};
553546

system-test/datastore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var env = require('./env.js');
2323
var Datastore = require('../lib/datastore/index.js');
2424
var entity = require('../lib/datastore/entity.js');
2525

26-
describe.only('Datastore', function() {
26+
describe('Datastore', function() {
2727
var testKinds = [];
2828
var datastore = new Datastore(env);
2929

test/common/stream-router.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,6 @@ describe('streamRouter', function() {
186186
assert.strictEqual(parsedArguments.maxResults, args[0].maxResults);
187187
});
188188

189-
it('should set maxResults from query.limitVal', function() {
190-
var args = [ { limitVal: 10 } ];
191-
var parsedArguments = streamRouter.parseArguments_(args);
192-
193-
assert.strictEqual(parsedArguments.maxResults, args[0].limitVal);
194-
});
195-
196189
it('should set maxResults from query.pageSize', function() {
197190
var args = [ { pageSize: 10 } ];
198191
var parsedArguments = streamRouter.parseArguments_(args);
@@ -213,13 +206,6 @@ describe('streamRouter', function() {
213206

214207
assert.strictEqual(parsedArguments.autoPaginate, false);
215208
});
216-
217-
it('should set autoPaginate: false with query.autoPaginateVal', function() {
218-
var args = [ { autoPaginateVal: false }, util.noop ];
219-
var parsedArguments = streamRouter.parseArguments_(args);
220-
221-
assert.strictEqual(parsedArguments.autoPaginate, false);
222-
});
223209
});
224210

225211
describe('router_', function() {

test/datastore/query.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,6 @@ describe('Query', function() {
5555
assert.strictEqual(query.namespace, null);
5656
});
5757
});
58-
59-
it('should enable auto pagination by default', function() {
60-
assert.strictEqual(query.autoPaginateVal, true);
61-
});
62-
});
63-
64-
describe('autoPaginate', function() {
65-
it('should enable auto pagination', function() {
66-
var query = new Query(['kind1']).autoPaginate();
67-
68-
assert.strictEqual(query.autoPaginateVal, true);
69-
});
70-
71-
it('should disable auto pagination when false is passed in', function() {
72-
var query = new Query(['kind1']).autoPaginate(false);
73-
74-
assert.strictEqual(query.autoPaginateVal, false);
75-
});
76-
77-
it('should not disable auto pagination with falsy values', function() {
78-
var query = new Query(['kind1']).autoPaginate(null);
79-
80-
assert.strictEqual(query.autoPaginateVal, true);
81-
});
82-
83-
it('should return the query instance', function() {
84-
var query = new Query(['kind1']);
85-
var nextQuery = query.autoPaginate(false);
86-
87-
assert.strictEqual(query, nextQuery);
88-
});
8958
});
9059

9160
describe('filter', function() {

0 commit comments

Comments
 (0)