Skip to content

Commit

Permalink
common.logBuffersIfDifferent()
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Dec 20, 2016
1 parent 5f00f54 commit 5cca06e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "txt-to-sql",
"description": "Tools for convert text data to SQL sentences",
"version": "0.0.24",
"version": "0.0.25",
"author": "Codenautas <codenautas@googlegroups.com>",
"repository": "codenautas/txt-to-sql",
"contributors": [{
Expand Down
9 changes: 9 additions & 0 deletions test/test-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ me.loadDefaultExpectedResult = function loadDefaultExpectedResult() {
return Promise.resolve(me.defaultExpectedResult);
}

me.logBuffersIfDifferent = function logBuffersIfDifferent(gen, exp) {
var comp = txtToSql.compareBuffers(gen, exp);
if(comp !==-1) {
console.log("GEN '"+gen+"'");
console.log("EXP '"+exp+"'")
console.log("DIFF STARTS in "+parseInt(comp,10), "\n"+(exp.length>gen.length ? exp : gen).toString().substring(comp))
}
}

module.exports = me;
9 changes: 2 additions & 7 deletions test/test-fast.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@ describe("fast-fixtures", function(){
var gen = generated.lines.join('');
var eparts = expected.rawSql.toString().split("\n\n");
// extraemos el insert
var exp = eparts[eparts.length-1].trimLeft()+'\n';
var comp = txtToSql.compareBuffers(gen, exp);
if(comp !==-1) {
console.log("GEN '"+gen+"'");
console.log("EXP '"+exp+"'")
console.log("diff in ", comp, "\n"+exp.substring(comp))
}
var exp = eparts[eparts.length-1].trimLeft()+'\n';
common.logBuffersIfDifferent(exp,gen);
expect(gen).to.eql(exp);
}).then(done,done);
});
Expand Down
7 changes: 1 addition & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ describe("fixtures", function(){
}
// generated
expect(generated.errors).to.eql(expected.errors);
var comp = txtToSql.compareBuffers(generated.rawSql, expected.rawSql);
if(comp !==-1) {
console.log("GEN", generated.rawSql.toString());
console.log("EXP", expected.rawSql.toString());
console.log("diff in ", comp, "\n"+expected.rawSql.toString().substring(comp))
}
common.logBuffersIfDifferent(generated.rawSql,expected.rawSql);
expect(generated.rawSql).to.eql(expected.rawSql);
expect(discrepances(generated.rawSql,expected.rawSql)).to.eql(null);
// coherencia entre prepared y generated
Expand Down

0 comments on commit 5cca06e

Please sign in to comment.