Permalink
Browse files

Merge pull request #15 from flatiron/gh-12

  • Loading branch information...
1 parent 737b052 commit 148da2f51e94deb90dd851663059fbb8bf4e2fd1 @pksunkara pksunkara committed Mar 27, 2012
Showing with 33 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +32 −1 test/streaming-test.js
View
@@ -1,5 +1,6 @@
node_modules
npm-debug.log
+test/fixtures/*-test.txt
examples/*.txt
examples/simple/*.txt
.DS_Store
View
@@ -1,6 +1,8 @@
var assert = require('assert'),
- vows = require('vows'),
+ fs = require('fs'),
+ path = require('path'),
request = require('request'),
+ vows = require('vows'),
union = require('../');
vows.describe('union/streaming').addBatch({
@@ -25,6 +27,35 @@ vows.describe('union/streaming').addBatch({
'should receive complete POST data': function (chunks) {
assert.equal(chunks, 'hello world');
}
+ },
+ "a simple pipe to a file": {
+ topic: function () {
+ var self = this;
+
+ union.createServer({
+ before: [
+ function (req, res, next) {
+ var filename = path.join(__dirname, 'fixtures', 'pipe-write-test.txt'),
+ writeStream = fs.createWriteStream(filename);
+
+ req.pipe(writeStream);
+ writeStream.on('close', function () {
+ res.writeHead(200);
+ fs.createReadStream(filename).pipe(res);
+ });
+ }
+ ]
+ }).listen(9044, function () {
+ request({
+ method: 'POST',
+ uri: 'http://localhost:9044',
+ body: 'hello world'
+ }, self.callback);
+ });
+ },
+ 'should receive complete POST data': function (err, res, body) {
+ assert.equal(body, 'hello world');
+ }
}
}
}).export(module);

0 comments on commit 148da2f

Please sign in to comment.