[ingest] small tweek
This commit is contained in:
parent
7c57c34e46
commit
7278cb31aa
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import processESIngestSimulateResponse from '../../../lib/process_es_ingest_simulate_response';
|
||||
import handleResponse from '../../../lib/process_es_ingest_simulate_response';
|
||||
import processESIngestSimulateError from '../../../lib/process_es_ingest_simulate_error';
|
||||
import simulateRequestSchema from '../../../lib/schemas/simulate_request_schema';
|
||||
import ingestSimulateApiKibanaToEsConverter from '../../../lib/converters/ingest_simulate_api_kibana_to_es_converter';
|
||||
|
@ -19,7 +19,6 @@ export function registerSimulate(server) {
|
|||
const simulateApiDocument = request.payload;
|
||||
const body = ingestSimulateApiKibanaToEsConverter(simulateApiDocument);
|
||||
|
||||
const handleResponse = processESIngestSimulateResponse;
|
||||
const handleError = _.partial(processESIngestSimulateError, simulateApiDocument.dirty_processor_id);
|
||||
|
||||
return boundCallWithRequest('transport.request', {
|
||||
|
|
67
test/unit/api/ingest/processors/_gsub.js
Normal file
67
test/unit/api/ingest/processors/_gsub.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
define(function (require) {
|
||||
var Promise = require('bluebird');
|
||||
var _ = require('intern/dojo/node!lodash');
|
||||
var expect = require('intern/dojo/node!expect.js');
|
||||
|
||||
const testPipeline = {
|
||||
processors: [{
|
||||
processor_id: 'processor1',
|
||||
type_id: 'gsub',
|
||||
target_field: 'foo',
|
||||
value: 'bar'
|
||||
}],
|
||||
input: {}
|
||||
};
|
||||
|
||||
return function (bdd, scenarioManager, request) {
|
||||
bdd.describe('simulate - set processor', function simulatePipeline() {
|
||||
|
||||
bdd.it('should return 400 for an invalid payload', function invalidPayload() {
|
||||
return Promise.all([
|
||||
// Set processor requires targetField property
|
||||
request.post('/kibana/ingest/simulate')
|
||||
.send({
|
||||
input: {},
|
||||
processors: [{
|
||||
processor_id: 'processor1',
|
||||
type_id: 'set',
|
||||
value: 'bar',
|
||||
target_field: 42
|
||||
}]
|
||||
})
|
||||
.expect(400)
|
||||
]);
|
||||
});
|
||||
|
||||
bdd.it('should return 200 for a valid simulate request', function validSetSimulate() {
|
||||
return request.post('/kibana/ingest/simulate')
|
||||
.send(testPipeline)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
bdd.it('should return a simulated output with the correct result for the given processor', function () {
|
||||
return request.post('/kibana/ingest/simulate')
|
||||
.send(testPipeline)
|
||||
.expect(200)
|
||||
.then(function (response) {
|
||||
expect(response.body[0].output.foo).to.be.equal('bar');
|
||||
});
|
||||
});
|
||||
|
||||
bdd.it('should enforce snake case', function setSimulateSnakeCase() {
|
||||
return request.post('/kibana/ingest/simulate')
|
||||
.send({
|
||||
processors: [{
|
||||
processorId: 'processor1',
|
||||
typeId: 'set',
|
||||
targetField: 'foo',
|
||||
value: 'bar'
|
||||
}],
|
||||
input: {}
|
||||
})
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
});
|
Loading…
Reference in a new issue