Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Teste unitário tabela de soma.
this.shouldaddIntoUndefinedGroup = function () {
var sumQuery = "SELECT * from TM_LOT where lot is null";
//var sumQ2 = "SELECT * from tmovimentation_agg_delta";
var sumDsBefore = database.query(sumQuery);
var tableDs = connection.copyStructureLocalCache('tmovimentation');
for (i=0; i<= 49; i++) {
tableDs.append();
tableDs.ikey = connection.createKey();
tableDs.iclass = -1891169235;
tableDs.emission = new Date('2014', '3', '26');
tableDs.emissionh = 2;
tableDs.available = 300;
tableDs.value = 400;
tableDs.product = 3;
tableDs.post();
}
tableDs.applyUpdates();
var sumDsAfter = database.query(sumQuery);
//A diferença entre o que tem na tabela de soma agora e antes deve ser exatamente
//o que foi inserido.
assert.equal(sumDsAfter.getField('value') - sumDsBefore.getField('value'), 20000);
assert.equal(sumDsAfter.getField('available') - sumDsBefore.getField('available'), 15000);
var aggTableManager = new ngin.sumtable.AggregateTableManager(-1891169229, ngin.global.database);
aggTableManager.updateMaterializedView('TM_LOT');
var sumDS2 = database.query(sumQuery);
assert.equal(sumDS2.getField('value') - sumDsBefore.getField('value'), 20000);
assert.equal(sumDS2.getField('available') - sumDsBefore.getField('available'), 15000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.