mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Test PUTting index patterns
This commit is contained in:
parent
118608cd95
commit
68d3be8b8d
3 changed files with 47 additions and 1 deletions
|
@ -87,7 +87,7 @@ export default function (server) {
|
|||
stitchPatternAndMappings
|
||||
).then(removeDeprecatedFieldProps)
|
||||
.then(function (pattern) {
|
||||
reply(pattern);
|
||||
reply(_.isArray(pattern) ? pattern[0] : pattern);
|
||||
}, function (error) {
|
||||
reply(handleESError(error));
|
||||
});
|
||||
|
|
44
test/unit/api/index_patterns/_put.js
Normal file
44
test/unit/api/index_patterns/_put.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
define(function (require) {
|
||||
var Promise = require('bluebird');
|
||||
var createTestData = require('intern/dojo/node!../../../unit/api/index_patterns/data');
|
||||
var _ = require('intern/dojo/node!lodash');
|
||||
var expect = require('intern/dojo/node!expect.js');
|
||||
|
||||
return function (bdd, scenarioManager, request) {
|
||||
|
||||
bdd.describe('PUT index-patterns', function putIndexPatterns() {
|
||||
|
||||
bdd.beforeEach(function () {
|
||||
return scenarioManager.reload('emptyKibana').then(function () {
|
||||
return request.post('/index-patterns').send(createTestData().indexPatternWithMappings);
|
||||
});
|
||||
});
|
||||
|
||||
bdd.afterEach(function () {
|
||||
return request.del('/index-patterns/logstash-*');
|
||||
});
|
||||
|
||||
bdd.it('should return 200 for a successful update', function () {
|
||||
var pattern = createTestData().indexPatternWithMappings;
|
||||
pattern.fields = _.map(pattern.fields, function (field) {
|
||||
return _.omit(field, 'mapping');
|
||||
});
|
||||
pattern.timeFieldName = 'foo';
|
||||
pattern.fields[0].count = 5;
|
||||
|
||||
return request.put('/index-patterns/logstash-*')
|
||||
.send(pattern)
|
||||
.expect(200)
|
||||
.then(function () {
|
||||
return request.get('/index-patterns/logstash-*');
|
||||
})
|
||||
.then(function (res) {
|
||||
expect(res.body.timeFieldName).to.be('foo');
|
||||
expect(res.body.fields[0].count).to.be(5);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
});
|
|
@ -8,6 +8,7 @@ define(function (require) {
|
|||
var expect = require('intern/dojo/node!expect.js');
|
||||
var post = require('./_post');
|
||||
var get = require('./_get');
|
||||
var put = require('./_put');
|
||||
|
||||
bdd.describe('index-patterns API', function () {
|
||||
var scenarioManager = new ScenarioManager(url.format(config.servers.elasticsearch));
|
||||
|
@ -23,5 +24,6 @@ define(function (require) {
|
|||
|
||||
get(bdd, scenarioManager, request);
|
||||
post(bdd, scenarioManager, request);
|
||||
put(bdd, scenarioManager, request);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue