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

[WIP] remove obsolete strict mode option #809

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion lib/models/entitiesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function findSilentEntitiesByMongo(service, subservice, ruleData, alterFunc, cal

async.waterfall(
[
db.collection.bind(db, entitiesCollectionName, { strict: false }),
db.collection.bind(db, entitiesCollectionName),
function(col, cb) {
col.find(criterion)
.batchSize(config.orionDb.batchSize)
Expand Down
6 changes: 3 additions & 3 deletions lib/models/executionsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
id = task.event.id,
index = task.action.index;

db.collection(execCollectionName, { strict: true }, function(err, col) {
db.collection(execCollectionName, function(err, col) {
if (err) {
myutils.logErrorIf(err);
return callback(err, null);
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = {
id = task.event.id,
index = task.action.index,
noticeId = task.event.noticeId;
db.collection(execCollectionName, { strict: true }, function(err, col) {
db.collection(execCollectionName, function(err, col) {
if (err) {
myutils.logErrorIf(err);
return callback(err, null);
Expand Down Expand Up @@ -107,7 +107,7 @@ module.exports = {
noticeId = task.event.noticeId;
async.waterfall(
[
db.collection.bind(db, execCollectionName, { strict: true }),
db.collection.bind(db, execCollectionName),
function(col, cb) {
col.update(
{
Expand Down
10 changes: 5 additions & 5 deletions lib/models/rulesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function search(rule, callback) {
var db = appContext.Db();
async.waterfall(
[
db.collection.bind(db, rulesCollectionName, { strict: true }),
db.collection.bind(db, rulesCollectionName),
function(col, cb) {
col.findOne({ name: rule.name, subservice: rule.subservice, service: rule.service }, cb);
}
Expand All @@ -107,7 +107,7 @@ function findAll(service, subservice, callback) {
var db = appContext.Db();
async.waterfall(
[
db.collection.bind(db, rulesCollectionName, { strict: true }),
db.collection.bind(db, rulesCollectionName),
function(col, cb) {
col.find(criterion).toArray(function(err, rules) {
if (rules && util.isArray(rules)) {
Expand Down Expand Up @@ -153,7 +153,7 @@ module.exports = {
var db = appContext.Db();
async.waterfall(
[
db.collection.bind(db, rulesCollectionName, { strict: true }),
db.collection.bind(db, rulesCollectionName),
function(col, cb) {
col.deleteOne({ name: rule.name, subservice: rule.subservice, service: rule.service }, cb);
}
Expand All @@ -170,7 +170,7 @@ module.exports = {
stringifyPostAxnParams(r);
async.waterfall(
[
db.collection.bind(db, rulesCollectionName, { strict: true }),
db.collection.bind(db, rulesCollectionName),
function(col, cb) {
col.insertOne(r, cb);
}
Expand All @@ -187,7 +187,7 @@ module.exports = {
stringifyPostAxnParams(r);
async.waterfall(
[
db.collection.bind(db, rulesCollectionName, { strict: true }),
db.collection.bind(db, rulesCollectionName),
function(col, cb) {
col.findOneAndUpdate(
{
Expand Down
204 changes: 102 additions & 102 deletions test/component/rules_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,34 +321,34 @@ describe('Rules', function() {
done
);
});
it('should return an error when something goes wrong in database', function(done) {
var cases = utilsT.loadDirExamples('./test/data/good_rules');
async.series(
[
utilsT.dropRulesCollection,
function(callback0) {
async.eachSeries(
cases,
function(c, callback) {
clients.PostRule(c.object, function(error, data) {
should.not.exist(error);
data.should.have.property('statusCode', 500);
return callback(null);
});
},
function(error) {
should.not.exist(error);
callback0();
}
);
}
],
function(error) {
should.not.exist(error);
done();
}
);
});
// it('should return an error when something goes wrong in database', function(done) {
// var cases = utilsT.loadDirExamples('./test/data/good_rules');
// async.series(
// [
// utilsT.dropRulesCollection,
// function(callback0) {
// async.eachSeries(
// cases,
// function(c, callback) {
// clients.PostRule(c.object, function(error, data) {
// should.not.exist(error);
// data.should.have.property('statusCode', 500);
// return callback(null);
// });
// },
// function(error) {
// should.not.exist(error);
// callback0();
// }
// );
// }
// ],
// function(error) {
// should.not.exist(error);
// done();
// }
// );
// });
});
describe('#DeletetRule()', function() {
it('should be OK to delete a nonexistent rule', function(done) {
Expand Down Expand Up @@ -389,34 +389,34 @@ describe('Rules', function() {
return done();
});
});
it('should return an error when something goes wrong in database', function(done) {
var cases = utilsT.loadDirExamples('./test/data/good_rules');
async.series(
[
utilsT.dropRulesCollection,
function(callback0) {
async.eachSeries(
cases,
function(c, callback) {
clients.DeleteRule(c.object.name, function(error, data) {
should.not.exist(error);
data.should.have.property('statusCode', 500);
return callback(null);
});
},
function(error) {
should.not.exist(error);
callback0();
}
);
}
],
function(error) {
should.not.exist(error);
done();
}
);
});
// it('should return an error when something goes wrong in database', function(done) {
// var cases = utilsT.loadDirExamples('./test/data/good_rules');
// async.series(
// [
// utilsT.dropRulesCollection,
// function(callback0) {
// async.eachSeries(
// cases,
// function(c, callback) {
// clients.DeleteRule(c.object.name, function(error, data) {
// should.not.exist(error);
// data.should.have.property('statusCode', 500);
// return callback(null);
// });
// },
// function(error) {
// should.not.exist(error);
// callback0();
// }
// );
// }
// ],
// function(error) {
// should.not.exist(error);
// done();
// }
// );
// });
});
describe('#GetRule()', function() {
it('should return NOT FOUND when the rule does not exist', function(done) {
Expand Down Expand Up @@ -448,34 +448,34 @@ describe('Rules', function() {
done
);
});
it('should return an error when something goes wrong in database', function(done) {
var cases = utilsT.loadDirExamples('./test/data/good_rules');
async.series(
[
utilsT.dropRulesCollection,
function(callback0) {
async.eachSeries(
cases,
function(c, callback) {
clients.GetRule(c.object.name, function(error, data) {
should.not.exist(error);
data.should.have.property('statusCode', 500);
return callback(null);
});
},
function(error) {
should.not.exist(error);
callback0();
}
);
}
],
function(error) {
should.not.exist(error);
done();
}
);
});
// it('should return an error when something goes wrong in database', function(done) {
// var cases = utilsT.loadDirExamples('./test/data/good_rules');
// async.series(
// [
// utilsT.dropRulesCollection,
// function(callback0) {
// async.eachSeries(
// cases,
// function(c, callback) {
// clients.GetRule(c.object.name, function(error, data) {
// should.not.exist(error);
// data.should.have.property('statusCode', 500);
// return callback(null);
// });
// },
// function(error) {
// should.not.exist(error);
// callback0();
// }
// );
// }
// ],
// function(error) {
// should.not.exist(error);
// done();
// }
// );
// });
});
describe('#GetAllRules()', function() {
it('should return an empty set when there are no rules', function(done) {
Expand All @@ -485,23 +485,23 @@ describe('Rules', function() {
return done();
});
});
it('should return an error when something goes wrong in database', function(done) {
async.series(
[
utilsT.dropRulesCollection,
function(callback) {
clients.GetAllRules(function(error, data) {
should.not.exist(error);
data.should.have.property('statusCode', 500);
return callback(null);
});
}
],
function(error) {
should.not.exist(error);
done();
}
);
});
// it('should return an error when something goes wrong in database', function(done) {
// async.series(
// [
// utilsT.dropRulesCollection,
// function(callback) {
// clients.GetAllRules(function(error, data) {
// should.not.exist(error);
// data.should.have.property('statusCode', 500);
// return callback(null);
// });
// }
// ],
// function(error) {
// should.not.exist(error);
// done();
// }
// );
// });
});
});
Loading
Loading