mirror of
https://github.com/cwinfo/hyperboria-peers.git
synced 2024-11-22 10:40:26 +00:00
more thorough js tests
This commit is contained in:
parent
bfc3a41fb8
commit
deaea22c4d
27
tests.js
27
tests.js
@ -37,23 +37,40 @@ if (credsWithDns.length) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var requiredFields = ['password', 'publicKey', 'contact'];
|
var requiredFields = ['password', 'publicKey', 'contact'];
|
||||||
|
var recommendedFields = ['gpg'];
|
||||||
|
|
||||||
var insufficientFields = Peers.filter(function (x, p) {
|
var insufficientFields = Peers.filter(function (x, p) {
|
||||||
var problem = false;
|
var problem = false;
|
||||||
|
var comment = false;
|
||||||
|
|
||||||
|
var path = '/' + p.join('/');
|
||||||
|
|
||||||
|
var requiredMsg = "[%s] => %s is missing the required field '%s'";
|
||||||
|
var recommendedMsg = "[%s] => '%s' is missing the recommended field '%s'";
|
||||||
Object.keys(x).map(function (k) {
|
Object.keys(x).map(function (k) {
|
||||||
var cred = x[k];
|
var cred = x[k];
|
||||||
var fields = Object.keys(cred);
|
var fields = Object.keys(cred);
|
||||||
requiredFields.forEach(function (field) {
|
|
||||||
if (fields.indexOf(field) === -1) {
|
recommendedFields.forEach(function (field) {
|
||||||
|
if (typeof(cred[field]) !== 'undefined') { return; }
|
||||||
|
console.log(recommendedMsg, path, k, field);
|
||||||
|
comment = true;
|
||||||
problem = true;
|
problem = true;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
requiredFields.forEach(function (field) {
|
||||||
|
if (typeof(cred[field]) !== 'undefined') { return; }
|
||||||
|
console.error(requiredMsg, path, k, field);
|
||||||
|
problem = true;
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//if (comment || problem) { console.log(); }
|
||||||
return problem;
|
return problem;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (insufficientFields.length) {
|
if (insufficientFields.length) {
|
||||||
console.log("The following peers did not have all the required fields");
|
//console.log("The following peers did not have all the required fields");
|
||||||
console.log(insufficientFields);
|
//console.log(insufficientFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user