Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test): Add precommit-hook #344

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"nonbsp": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"undef": true,
"unused": false,
"maxparams": 4,
"maxdepth": 4
"maxdepth": 4,
"maxlen": 140
}
2 changes: 1 addition & 1 deletion integration/analyzer_peliasHousenumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};
10 changes: 5 additions & 5 deletions integration/analyzer_peliasIndexOneEdgeGram.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,17 @@ module.exports.tests.unicode = function(test, common){

// Chambéry (both forms appear the same)
var composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry";

assertAnalysis( 'composed', composed, ['c', 'ch', 'cha', 'cham', 'chamb', 'chambe', 'chamber', 'chambery'] );
assertAnalysis( 'decomposed', decomposed, ['c', 'ch', 'cha', 'cham', 'chamb', 'chambe', 'chamber', 'chambery'] );

// Één (both forms appear the same)
var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"
var composed2 = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed2 = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n";

assertAnalysis( 'composed', composed, ['e','ee','een'] );
assertAnalysis( 'decomposed', decomposed, ['e','ee','een'] );
assertAnalysis( 'composed', composed2, ['e','ee','een'] );
assertAnalysis( 'decomposed', decomposed2, ['e','ee','een'] );

suite.run( t.end );
});
Expand Down
10 changes: 5 additions & 5 deletions integration/analyzer_peliasPhrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,17 @@ module.exports.tests.unicode = function(test, common){

// Chambéry (both forms appear the same)
var composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry";

assertAnalysis( 'composed', composed, ['chambery'] );
assertAnalysis( 'decomposed', decomposed, ['chambery'] );

// Één (both forms appear the same)
var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"
var composed2 = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed2 = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n";

assertAnalysis( 'composed', composed, ['een'] );
assertAnalysis( 'decomposed', decomposed, ['een'] );
assertAnalysis( 'composed', composed2, ['een'] );
assertAnalysis( 'decomposed', decomposed2, ['een'] );

suite.run( t.end );
});
Expand Down
16 changes: 8 additions & 8 deletions integration/analyzer_peliasQueryFullToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,18 @@ module.exports.tests.unicode = function(test, common){
var latin_small_letter_e = String.fromCodePoint(0x0065);

// Chambéry (both forms appear the same)
var composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"
var chambery_composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var chambery_decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry";

assertAnalysis( 'composed', composed, ['chambery'] );
assertAnalysis( 'decomposed', decomposed, ['chambery'] );
assertAnalysis( 'composed', chambery_composed, ['chambery'] );
assertAnalysis( 'decomposed', chambery_decomposed, ['chambery'] );

// Één (both forms appear the same)
var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"
var een_composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var een_decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n";

assertAnalysis( 'composed', composed, ['een'] );
assertAnalysis( 'decomposed', decomposed, ['een'] );
assertAnalysis( 'composed', een_composed, ['een'] );
assertAnalysis( 'decomposed', een_decomposed, ['een'] );

suite.run( t.end );
});
Expand Down
16 changes: 8 additions & 8 deletions integration/analyzer_peliasQueryPartialToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,18 @@ module.exports.tests.unicode = function(test, common){
var latin_small_letter_e = String.fromCodePoint(0x0065);

// Chambéry (both forms appear the same)
var composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"
var chambery_composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var chambery_decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry";

assertAnalysis( 'composed', composed, ['chambery'] );
assertAnalysis( 'decomposed', decomposed, ['chambery'] );
assertAnalysis( 'composed', chambery_composed, ['chambery'] );
assertAnalysis( 'decomposed', chambery_decomposed, ['chambery'] );

// Één (both forms appear the same)
var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"
var een_composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var een_decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n";

assertAnalysis( 'composed', composed, ['een'] );
assertAnalysis( 'decomposed', decomposed, ['een'] );
assertAnalysis( 'composed', een_composed, ['een'] );
assertAnalysis( 'decomposed', een_decomposed, ['een'] );

suite.run( t.end );
});
Expand Down
16 changes: 8 additions & 8 deletions integration/analyzer_peliasStreet.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,18 @@ module.exports.tests.unicode = function(test, common){
var latin_small_letter_e = String.fromCodePoint(0x0065);

// Chambéry (both forms appear the same)
var composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"
var chambery_composed = "Chamb" + latin_small_letter_e_with_acute + "ry";
var chambery_decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry";

assertAnalysis( 'composed', composed, ['chambery'] );
assertAnalysis( 'decomposed', decomposed, ['chambery'] );
assertAnalysis( 'composed', chambery_composed, ['chambery'] );
assertAnalysis( 'decomposed', chambery_decomposed, ['chambery'] );

// Één (both forms appear the same)
var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"
var een_composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n";
var een_decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n";

assertAnalysis( 'composed', composed, ['een'] );
assertAnalysis( 'decomposed', decomposed, ['een'] );
assertAnalysis( 'composed', een_composed, ['een'] );
assertAnalysis( 'decomposed', een_decomposed, ['een'] );

suite.run( t.end );
});
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"drop_index": "node scripts/drop_index",
"reset_type": "node scripts/reset_type",
"update_settings": "node scripts/update_settings",
"travis": "npm run test && npm run integration"
"travis": "npm run test && npm run integration",
"lint": "jshint .",
"validate": "npm ls"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,11 +45,17 @@
"devDependencies": {
"difflet": "^1.0.1",
"elastictest": "^2.0.0",
"precommit-hook": "^3.0.0",
"proxyquire": "^2.0.0",
"tap-spec": "^5.0.0",
"tape": "^4.5.0"
},
"pre-commit": [],
"pre-commit": [
"lint",
"prune",
"validate",
"test"
],
"release": {
"branch": "master",
"success": []
Expand Down
4 changes: 2 additions & 2 deletions scripts/check_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ client.nodes.info( null, function( err, res ){

// bool, is the plugin currently installed?
const isInstalled = !!node.plugins.filter( function( installedPlugin ){
return installedPlugin.name == plugin;
return installedPlugin.name === plugin;
}).length;

// output status to terminal
Expand Down Expand Up @@ -87,7 +87,7 @@ client.nodes.info( null, function( err, res ){
});
});
console.error( colors.white("\nnote:") + "some plugins may require you to restart elasticsearch.\n");
process.exit(1)
process.exit(1);
}

console.log();
Expand Down
2 changes: 1 addition & 1 deletion scripts/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ var util = require('util');
module.exports.header = function( text ){
var rule = new Array( text.length + 3 ).join("-");
console.log( util.format("\n\033[0;33m%s\n %s \n%s\033[0m\n", rule, text, rule ) );
}
};
11 changes: 8 additions & 3 deletions scripts/drop_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ var readline = require('readline'),
schema = require('../schema');

// use -f or --force-yes to skip the prompt
if( isForced() ) drop();
else prompt( drop, fail );
if( isForced() ) {
drop();
} else {
prompt( drop, fail );
}

function drop(){
client.indices.delete( { index: config.schema.indexName }, function( err, res ){
Expand All @@ -28,7 +31,9 @@ function warnIfNotLocal() {
function prompt( yes, no ){
warnIfNotLocal();
rl.question( 'Are you sure you want to drop the ' + config.schema.indexName + ' index and delete ALL records? ', function( answer ){
if( !answer.match(/^y(es)?$/i) ) return no();
if( !answer.match(/^y(es)?$/i) ) {
return no();
}
return yes();
});
}
Expand Down
12 changes: 6 additions & 6 deletions test/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ module.exports.tests.parent_analysis = function(test, common) {
});

test('postalcode', function(t) {
t.equal(prop['postalcode'].type, 'string');
t.equal(prop['postalcode'].analyzer, 'peliasZip');
t.equal(prop['postalcode'+'_a'].type, 'string');
t.equal(prop['postalcode'+'_a'].analyzer, 'peliasZip');
t.equal(prop['postalcode'+'_id'].type, 'string');
t.equal(prop['postalcode'+'_id'].index, 'not_analyzed');
t.equal(prop.postalcode.type, 'string');
t.equal(prop.postalcode.analyzer, 'peliasZip');
t.equal(prop.postalcode_a.type, 'string');
t.equal(prop.postalcode_a.analyzer, 'peliasZip');
t.equal(prop.postalcode_id.type, 'string');
t.equal(prop.postalcode_id.index, 'not_analyzed');

t.end();
});
Expand Down
8 changes: 4 additions & 4 deletions test/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,17 +443,17 @@ module.exports.tests.overrides = function(test, common) {
test('override defaults', function(t) {

var s = settings();
t.equal(s.index['number_of_replicas'], '0', 'unchanged');
t.equal(s.index.number_of_replicas, '0', 'unchanged');

// set the PELIAS_CONFIG env var
process.env['PELIAS_CONFIG'] = path.resolve( __dirname + '/fixtures/config.json' );
process.env.PELIAS_CONFIG = path.resolve( __dirname + '/fixtures/config.json' );

s = settings();
t.equal(s.index['number_of_replicas'], '999', 'changed');
t.equal(s.index.number_of_replicas, '999', 'changed');
t.end();

// unset the PELIAS_CONFIG env var
delete process.env['PELIAS_CONFIG'];
delete process.env.PELIAS_CONFIG;
});
};

Expand Down