mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
add mapper and tests
This commit is contained in:
parent
7f478ea60e
commit
d59079db86
3 changed files with 51 additions and 8 deletions
|
@ -6,18 +6,29 @@ define(function (require) {
|
|||
*
|
||||
* @class Mapper
|
||||
*/
|
||||
function Mapper(index, type) {
|
||||
this.indices = function () {
|
||||
function Mapper(client) {
|
||||
|
||||
/**
|
||||
* Gets an object containing all fields with their mappings
|
||||
* @param {dataSource} dataSource
|
||||
* @param {Number} type
|
||||
* @return {Object} A hash containing fields and their related mapping
|
||||
*/
|
||||
this.getFields = function (dataSource, type) {
|
||||
return {
|
||||
foo: {
|
||||
type: 'string'
|
||||
},
|
||||
'foo.bar': {
|
||||
type: 'long'
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
this.getFields = function () {
|
||||
|
||||
};
|
||||
|
||||
this.getFieldType = function (field, type) {
|
||||
this.getFieldType = function (dataSource, field, type) {
|
||||
return field, type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return Mapper;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Lint and build CSS
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('default', ['jshint:source']);
|
||||
grunt.registerTask('default', ['jshint:source','test']);
|
||||
};
|
32
test/unit/specs/mapper.js
Normal file
32
test/unit/specs/mapper.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
define(function (require) {
|
||||
var elasticsearch = require('elasticsearch');
|
||||
var _ = require('lodash');
|
||||
var Mapper = require('courier/mapper');
|
||||
|
||||
var client = new elasticsearch.Client({
|
||||
host: 'localhost:9200',
|
||||
});
|
||||
|
||||
describe('Mapper Module', function () {
|
||||
|
||||
it('provides a constructor for the Mapper class', function () {
|
||||
var mapper = new Mapper(client);
|
||||
expect(mapper).to.be.a(Mapper);
|
||||
});
|
||||
|
||||
it('has a function call getFields that returns an empty object', function () {
|
||||
var mapper = new Mapper(new Courier());
|
||||
expect(mapper.getFields()).to.eql({
|
||||
foo: {
|
||||
type: 'string'
|
||||
},
|
||||
"foo.bar": {
|
||||
type: 'long'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue