Merge pull request #3 from rashidkpc/master
Move test server to port 8001
This commit is contained in:
commit
a8129e1fc0
|
@ -6,18 +6,23 @@ 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 {Function} [callback] A function to be executed with the results.
|
||||
* @param {String} [type]
|
||||
* @return {Object} A hash containing fields and their related mapping
|
||||
*/
|
||||
this.getFields = function (dataSource, callback, type) {
|
||||
client.indices.getFieldMapping({index: dataSource.index}, callback);
|
||||
};
|
||||
|
||||
this.getFields = function () {
|
||||
|
||||
};
|
||||
|
||||
this.getFieldType = function (field, type) {
|
||||
this.getFieldType = function (dataSource, field, type) {
|
||||
return field, type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return Mapper;
|
||||
|
|
|
@ -20,7 +20,7 @@ define(function (require) {
|
|||
type: '@'
|
||||
},
|
||||
template: '<strong style="float:left">{{count}} : </strong><pre>{{json}}</pre>',
|
||||
controller: function ($rootScope, $scope) {
|
||||
controller: function ($rootScope, $scope, courier) {
|
||||
$scope.count = 0;
|
||||
|
||||
var source = $rootScope.dataSource.extend()
|
||||
|
@ -33,6 +33,10 @@ define(function (require) {
|
|||
$scope.json = JSON.stringify(resp.hits, null, ' ');
|
||||
});
|
||||
|
||||
courier.mapper.getFields($rootScope.dataSource, function (data) {
|
||||
$scope.json = data;
|
||||
});
|
||||
|
||||
$scope.$watch('type', source.type);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,7 +12,8 @@ module.exports = {
|
|||
'<%= src %>',
|
||||
'<%= root %>/node_modules/mocha',
|
||||
'<%= root %>/node_modules/expect.js'
|
||||
]
|
||||
],
|
||||
port: 8001
|
||||
}
|
||||
}
|
||||
};
|
|
@ -4,7 +4,7 @@ module.exports = {
|
|||
log: true,
|
||||
logErrors: true,
|
||||
urls: [
|
||||
'http://localhost:8000/'
|
||||
'http://localhost:8001/'
|
||||
],
|
||||
run: false
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Lint and build CSS
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('default', ['jshint:source']);
|
||||
grunt.registerTask('default', ['jshint:source','test']);
|
||||
};
|
|
@ -37,7 +37,8 @@
|
|||
})
|
||||
require([
|
||||
'/specs/courier.js',
|
||||
'/specs/data_source.js'
|
||||
'/specs/data_source.js',
|
||||
'/specs/mapper.js'
|
||||
], function () {
|
||||
window.mochaRunner = mocha.run().on('end', function(){
|
||||
window.mochaResults = this.stats;
|
||||
|
|
48
test/unit/specs/mapper.js
Normal file
48
test/unit/specs/mapper.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
define(function (require) {
|
||||
var elasticsearch = require('../bower_components/elasticsearch/elasticsearch.js');
|
||||
var _ = require('lodash');
|
||||
var Courier = require('courier/courier');
|
||||
var DataSource = require('courier/data_source/data_source');
|
||||
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 called getFields that returns an object', function () {
|
||||
/*
|
||||
var courier = new Courier({
|
||||
client: client
|
||||
});
|
||||
|
||||
var dataSource = courier.createSource('search')
|
||||
.index('_all')
|
||||
.size(5);
|
||||
|
||||
var mapper = new Mapper(client);
|
||||
|
||||
var callback = function(data) {
|
||||
console.log(data);
|
||||
};
|
||||
|
||||
expect(mapper.getFields(dataSource,callback)).to.eql({
|
||||
foo: {
|
||||
type: 'string'
|
||||
},
|
||||
"foo.bar": {
|
||||
type: 'long'
|
||||
}
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in a new issue