Skip to content

Commit

Permalink
Add test case assert
Browse files Browse the repository at this point in the history
  • Loading branch information
aleafs committed Jun 23, 2012
1 parent 443cbe7 commit 3ae910a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
7 changes: 3 additions & 4 deletions index.js
Expand Up @@ -110,6 +110,9 @@ exports.create = function (flist, prefix, options) {
reader.on('error', function (error) {
_complete(iError('StreamReadError', error.stack));
});
reader.on('end', function () {
_readfile(flist.shift());
});

var _tail = '';
reader.on('data', function (data) {
Expand Down Expand Up @@ -142,10 +145,6 @@ exports.create = function (flist, prefix, options) {
}
}
});

reader.on('end', function () {
_readfile(flist.shift());
});
};

return function (callback) {
Expand Down
21 changes: 16 additions & 5 deletions test/filesplit.test.js
Expand Up @@ -40,6 +40,7 @@ describe('file split', function () {
});
/* }}} */

/* {{{ should_file_split_works_fine() */
it('should_file_split_works_fine', function (done) {
var _input = [__dirname + '/res/test_input_1.txt', __dirname + '/res/test_input_2.txt'];
var caller = splitor.create(_input, __dirname + '/res/output', {
Expand All @@ -50,14 +51,24 @@ describe('file split', function () {
'fields' : [1,0,4,3],
});
caller(function (error, result) {
should.ok(!error);
JSON.stringify(result).should.eql(JSON.stringify({
'thedate=20120623' : [
__dirname + '/res/output.thedate=20120623.' + process.pid + '_0',
__dirname + '/res/output.thedate=20120623.' + process.pid + '_3',
],
'thedate=20120624' : [
__dirname + '/res/output.thedate=20120624.' + process.pid + '_1',
__dirname + '/res/output.thedate=20120624.' + process.pid + '_4',
],
'thedate=20120625' : [
__dirname + '/res/output.thedate=20120625.' + process.pid + '_2',
],
}));
done();
});
});
/* }}} */

/*
afterEach(function (done) {
cleanOutput(done);
});
*/
});

0 comments on commit 3ae910a

Please sign in to comment.