haraka-config
Advanced tools
Comparing version 1.0.5 to 1.0.6
# 1.0.6 - 2016-11-10 | ||
* handle invalid .ini lines properly (skip them) | ||
# 1.0.5 - 2016-10-25 | ||
@@ -3,0 +7,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"description": "Haraka's config file loader", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"homepage": "http://haraka.github.io", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -18,3 +18,2 @@ 'use strict'; | ||
var match; | ||
var is_array_match; | ||
var setter; | ||
@@ -49,5 +48,6 @@ var pre = ''; | ||
'Invalid line in config file \'' + name + '\': ' + line); | ||
return; | ||
} | ||
is_array_match = regex.is_array.exec(match[1]); | ||
var is_array_match = regex.is_array.exec(match[1]); | ||
if (is_array_match) { | ||
@@ -54,0 +54,0 @@ setter = function(key, value) { |
@@ -114,4 +114,6 @@ 'use strict'; | ||
var r = this.cfreader.load_config('test/config/test.ini', 'ini', { | ||
booleans: ['+sect1.bool_true','-sect1.bool_false', | ||
'+sect1.bool_true_default', 'sect1.-bool_false_default'] | ||
booleans: [ | ||
'+sect1.bool_true','-sect1.bool_false', | ||
'+sect1.bool_true_default', 'sect1.-bool_false_default' | ||
] | ||
}); | ||
@@ -303,1 +305,72 @@ test.strictEqual(r.sect1.bool_true, true); | ||
}; | ||
exports.regex = { | ||
setUp: _set_up, | ||
'section': function (test) { | ||
test.expect(4); | ||
test.equal(this.cfreader.regex.section.test('[foo]'), true); | ||
test.equal(this.cfreader.regex.section.test('bar'), false); | ||
test.equal(this.cfreader.regex.section.test('[bar'), false); | ||
test.equal(this.cfreader.regex.section.test('bar]'), false); | ||
test.done(); | ||
}, | ||
'param': function (test) { | ||
test.expect(2); | ||
test.equal(this.cfreader.regex.param.exec('foo=true')[1], 'foo'); | ||
test.equal(this.cfreader.regex.param.exec(';foo=true'), undefined); | ||
test.done(); | ||
}, | ||
'comment': function (test) { | ||
test.expect(2); | ||
test.equal(this.cfreader.regex.comment.test('; true'), true); | ||
test.equal(this.cfreader.regex.comment.test('false'), false); | ||
test.done(); | ||
}, | ||
'line': function (test) { | ||
test.expect(2); | ||
test.equal(this.cfreader.regex.line.test(' boo '), true); | ||
test.equal(this.cfreader.regex.line.test('foo'), true); | ||
test.done(); | ||
}, | ||
'blank': function (test) { | ||
test.expect(2); | ||
test.equal(this.cfreader.regex.blank.test('foo'), false); | ||
test.equal(this.cfreader.regex.blank.test(' '), true); | ||
test.done(); | ||
}, | ||
// 'continuation': function (test) { | ||
// test.expect(1); | ||
// test.done(); | ||
// }, | ||
'is_integer': function (test) { | ||
test.expect(3); | ||
test.equal(this.cfreader.regex.is_integer.test(1), true); | ||
test.equal(this.cfreader.regex.is_integer.test(''), false); | ||
test.equal(this.cfreader.regex.is_integer.test('a'), false); | ||
test.done(); | ||
}, | ||
'is_float': function (test) { | ||
test.expect(3); | ||
test.equal(this.cfreader.regex.is_float.test('1.0'), true); | ||
test.equal(this.cfreader.regex.is_float.test(''), false); | ||
test.equal(this.cfreader.regex.is_float.test('45'), false); | ||
test.done(); | ||
}, | ||
'is_truth': function (test) { | ||
test.expect(6); | ||
test.equal(this.cfreader.regex.is_truth.test('no'), false); | ||
test.equal(this.cfreader.regex.is_truth.test('nope'), false); | ||
test.equal(this.cfreader.regex.is_truth.test('nuh uh'), false); | ||
test.equal(this.cfreader.regex.is_truth.test('yes'), true); | ||
test.equal(this.cfreader.regex.is_truth.test('true'), true); | ||
test.equal(this.cfreader.regex.is_truth.test(true), true); | ||
test.done(); | ||
}, | ||
'is_array': function (test) { | ||
test.expect(3); | ||
test.equal(this.cfreader.regex.is_array.test('foo=bar'), false); | ||
test.equal(this.cfreader.regex.is_array.test('foo'), false); | ||
test.equal(this.cfreader.regex.is_array.test('foo[]'), true); | ||
test.done(); | ||
}, | ||
} |
@@ -29,7 +29,6 @@ 'use strict'; | ||
// console.log(result); | ||
test.deepEqual(result.main, | ||
{ bool_true: 'true', bool_false: 'false', | ||
str_true: 'true', str_false: 'false' | ||
} | ||
); | ||
test.deepEqual(result.main, { | ||
bool_true: 'true', bool_false: 'false', | ||
str_true: 'true', str_false: 'false' | ||
}); | ||
test.done(); | ||
@@ -158,1 +157,11 @@ }, | ||
}; | ||
exports.invalid = { | ||
setUp: _set_up, | ||
'goobers.ini has invalid entry' : function (test) { | ||
test.expect(1); | ||
var result = this.ini.load('test/config/goobers.ini', {}, regex); | ||
test.deepEqual(result, { main: { } } ); | ||
test.done(); | ||
}, | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69944
40
1623