forked from askmike/gekko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added nodeunit dependency, first dummy test passes and script for run…
…ning tests.
- Loading branch information
Showing
3 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
var nodeunit = require('nodeunit'); | ||
var reporter = nodeunit.reporters.default; | ||
reporter.run(['test']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,50 @@ | ||
var fs = require('fs'); | ||
var zlib = require('zlib'); | ||
var async = require('async'); | ||
|
||
var TMPDIR = "./tmp/" | ||
var TMPDIR = "./tmp/"; | ||
var CSVFILE = TMPDIR + "test.csv"; | ||
|
||
exports = { | ||
function deflate(file, data, next) { | ||
zlib.deflate(data, function(err, buffer) { next(err, file, buffer) }); | ||
} | ||
|
||
function save(file, buffer, next) { | ||
console.log("save", file, buffer, !!next); | ||
fs.writeFile(file, buffer, function(err) { next(err); }); | ||
} | ||
|
||
function cleanUp(path, next) { | ||
if( fs.existsSync(path) ) { | ||
var files = []; | ||
files = fs.readdirSync(path); | ||
files.forEach(function(file,index){ | ||
var curPath = path + "/" + file; | ||
if(fs.statSync(curPath).isDirectory()) { | ||
// recurse | ||
cleanUp(curPath); | ||
} else { | ||
// delete file | ||
fs.unlinkSync(curPath); | ||
} | ||
}); | ||
fs.rmdirSync(path); | ||
} | ||
next(null, path); | ||
} | ||
|
||
module.exports = { | ||
setUp: function(done) { | ||
var data = "1,2,3,4,5\n10,20,30,40,50"; | ||
fs.existsSync(TMPDIR) || fs.mkdir(TMPDIR); | ||
fs.writeFile(CSVFLE, data, done); | ||
fs.existsSync(TMPDIR) || fs.mkdirSync(TMPDIR); | ||
async.compose(save, deflate)(CSVFILE, data, done); | ||
}, | ||
tearDown: function(done) { | ||
fs.existsSync(TMPDIR) && fs.rm(TMPDIR); | ||
} | ||
fs.existsSync(TMPDIR) && cleanUp(TMPDIR, done); | ||
}, | ||
test_nodeunit: function(test) { | ||
console.log("Nodeunit invoked, Great!"); | ||
test.ok(true); | ||
test.done(); | ||
}, | ||
}; |