Skip to content

Commit

Permalink
Primeros tests para stringizeStats
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Nov 8, 2016
1 parent da79e08 commit bfd665f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,13 @@ function finalizeStats(info) {
}

function stringizeStats(stats) {
return JSON.stringify(stats);
var s=[];
s.push('rows:'+stats.rows);
s.push('columns:'+stats.columns+' (text:'+stats.textColumns+', null:'+stats.nullColumns+')');
if(stats.primaryKey.length) {
s.push('primary key:'+stats.primaryKey.join(','));
}
return s.join(', ');
}

function generateScripts(info){
Expand Down
15 changes: 15 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,18 @@ describe("file encoding", function(){
});
});

describe("stringizeStats", function(){
[
{stats:{rows:3,columns:3,textColumns:1, nullColumns:2, primaryKey:[]},
out:'rows:3, columns:3 (text:1, null:2)' },
].forEach(function(check, index) {
if(check.skip) {
it.skip(check.name);
} else {
it(JSON.stringify(index), function(){
expect(txtToSql.stringizeStats(check.stats)).to.eql(check.out);
});
}
});
});

8 changes: 7 additions & 1 deletion web/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,13 @@ function finalizeStats(info) {
}

function stringizeStats(stats) {
return JSON.stringify(stats);
var s=[];
s.push('rows:'+stats.rows);
s.push('columns:'+stats.columns+' (text:'+stats.textColumns+', null:'+stats.nullColumns+')');
if(stats.primaryKey.length) {
s.push('primary key:'+stats.primaryKey.join(','));
}
return s.join(', ');
}

function generateScripts(info){
Expand Down

0 comments on commit bfd665f

Please sign in to comment.