Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "batchdb", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "leveldb and disk storage for queued batch jobs", | ||
@@ -20,2 +20,3 @@ "main": "index.js", | ||
"mkdirp": "~0.5.0", | ||
"split": "^0.3.0", | ||
"tape": "^2.13.2" | ||
@@ -22,0 +23,0 @@ }, |
var test = require('tape'); | ||
var batchdb = require('../'); | ||
var mkdirp = require('mkdirp'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
var spawn = require('child_process').spawn; | ||
var duplexer = require('duplexer'); | ||
var concat = require('concat-stream'); | ||
var through = require('through2'); | ||
var split = require('split'); | ||
var os = require('os'); | ||
@@ -26,5 +27,5 @@ var tmpdir = path.join((os.tmpdir || os.tmpDir)(), 'batchdb.' + Math.random()); | ||
[ 'RESULT', 'c0320d2f8e6fcee8145cdf7a8cb0fe11bf5820e44390097300adf05ad0ddbca5' ], | ||
os.hostname() + '\n', | ||
'beep\n', | ||
[ 'RESULT', '3435bb0065250a67c226fdcb1aefab113b738d17e4f43004b9b9d642e31fec10' ], | ||
__dirname + '\n', | ||
'/home/robots\n', | ||
[ 'RESULT', 'cda14a731876c0775efc30845bd3a8514e87502afb19919de858afed91e6adc0' ], | ||
@@ -36,3 +37,3 @@ 'beep boop\n' | ||
t.plan(expected.length); | ||
var compute = batchdb(db, { path: path.join(tmpdir, 'blobs'), run: run }); | ||
var compute = batchdb(db, { path: path.join(tmpdir, 'blobs'), run: fake }); | ||
@@ -62,7 +63,21 @@ compute.on('create', function (key) { | ||
compute.run(); | ||
function run (key) { | ||
var ps = spawn('bash', [], { cwd: __dirname }); | ||
return duplexer(ps.stdin, ps.stdout); | ||
} | ||
}); | ||
function fake () { | ||
var input = split(); | ||
var output = through(function (buf, enc, next) { | ||
var line = buf.toString('utf8'); | ||
if (line === 'sleep 1; hostname') { | ||
this.push('beep\n'); | ||
} | ||
else if (line === 'sleep 1; pwd') { | ||
this.push('/home/robots\n'); | ||
} | ||
else if (line === 'sleep 1; echo beep boop') { | ||
this.push('beep boop\n'); | ||
} | ||
next(); | ||
}); | ||
input.pipe(output); | ||
return duplexer(input, output); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18587
352
200
1
6