add get method to Client, add errors to mock
This commit is contained in:
32
test/fixtures/elasticsearch.js
vendored
32
test/fixtures/elasticsearch.js
vendored
@@ -1,4 +1,5 @@
|
||||
import { uniqueId } from 'lodash';
|
||||
import elasticsearch from 'elasticsearch';
|
||||
|
||||
function Client() {
|
||||
this.indices = {
|
||||
@@ -25,6 +26,33 @@ Client.prototype.ping = function () {
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
export default {
|
||||
Client: Client
|
||||
Client.prototype.get = function (params, source) {
|
||||
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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user