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