From 5431976e1b27874a2649b9f4e9bddadbaa33f52b Mon Sep 17 00:00:00 2001 From: Adrien Maret Date: Mon, 12 Aug 2019 10:52:11 +0200 Subject: [PATCH] Fix wrong return value from collection:truncate (#1380) Currently collection:truncate returns the list of deleted document IDs. This PR change the return value to match the documentation with { acknowledged: true } --- lib/api/controllers/collectionController.js | 8 ++++---- test/api/controllers/collectionController.test.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/api/controllers/collectionController.js b/lib/api/controllers/collectionController.js index afe394f29c..9325d23293 100644 --- a/lib/api/controllers/collectionController.js +++ b/lib/api/controllers/collectionController.js @@ -262,7 +262,8 @@ class CollectionController extends BaseController { truncate(request) { assertHasIndexAndCollection(request); - return this.engine.truncateCollection(request); + return this.engine.truncateCollection(request) + .then(() => ({ acknowledged: true })); } /** @@ -270,8 +271,7 @@ class CollectionController extends BaseController { * @returns {Promise} */ list(request) { - const - type = request.input.args.type ? request.input.args.type : 'all'; + const type = request.input.args.type || 'all'; assertHasIndex(request); @@ -283,7 +283,7 @@ class CollectionController extends BaseController { if (type === 'realtime' || type === 'all') { collections = this.kuzzle.hotelClerk.getRealtimeCollections( - request.input.resource.index).map(name => ({name, type: 'realtime'})); + request.input.resource.index).map(name => ({ name, type: 'realtime' })); } return Bluebird.resolve() diff --git a/test/api/controllers/collectionController.test.js b/test/api/controllers/collectionController.test.js index a5b5532623..71a57a095a 100644 --- a/test/api/controllers/collectionController.test.js +++ b/test/api/controllers/collectionController.test.js @@ -91,7 +91,7 @@ describe('Test: collection controller', () => { should(truncate).be.calledWith(request); should(response).be.instanceof(Object); - should(response).match(foo); + should(response).match({ acknowledged: true }); }); }); });