add get method to Client, add errors to mock

This commit is contained in:
2016-04-25 14:19:48 -07:00
parent c79da26f2d
commit a4bfd5184d

View File

@@ -1,4 +1,5 @@
import { uniqueId } from 'lodash'; import { uniqueId } from 'lodash';
import elasticsearch from 'elasticsearch';
function Client() { function Client() {
this.indices = { this.indices = {
@@ -25,6 +26,33 @@ Client.prototype.ping = function () {
return Promise.resolve(); return Promise.resolve();
}; };
export default { Client.prototype.get = function (params, source) {
Client: Client if (params === elasticsearch.errors.NotFound) return elasticsearch.errors.NotFound;
const _source = source || {
payload: {
id: 'sample-job-1',
now: 'Mon Apr 25 2016 14:13:04 GMT-0700 (MST)'
},
priority: 10,
timeout: 10000,
created_at: '2016-04-25T21:13:04.738Z',
attempts: 0,
max_attempts: 3,
status: 'pending'
};
return {
_index: params.index,
_type: params.type,
_id: params.id || 'AVRPRLnlp7Ur1SZXfT-T',
_version: params.version || 1,
found: true,
_source: _source
};
};
export default {
Client: Client,
errors: elasticsearch.errors
}; };