|
@ -17,9 +17,8 @@ var http = require("http"), |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var emails = fixture.messages.slice(0), |
|
|
var emails = fixture.messages.slice(0), |
|
|
chunkSize = 1, // set to minimum to forcibly expose boundary conditions.
|
|
|
chunkSize = 1; // set to minimum to forcibly expose boundary conditions.
|
|
|
// in a real scenario, this would be much much bigger.
|
|
|
// in a real scenario, this would be much much bigger.
|
|
|
firstPart = new (events.Promise); |
|
|
|
|
|
|
|
|
|
|
|
// test streaming messages through directly, as if they were in a file or something.
|
|
|
// test streaming messages through directly, as if they were in a file or something.
|
|
|
sys.puts("test "+emails.length+" emails"); |
|
|
sys.puts("test "+emails.length+" emails"); |
|
@ -30,7 +29,7 @@ sys.puts("test "+emails.length+" emails"); |
|
|
|
|
|
|
|
|
if (!email) { |
|
|
if (!email) { |
|
|
sys.puts("done testing emails"); |
|
|
sys.puts("done testing emails"); |
|
|
firstPart.emitSuccess(); |
|
|
testGoodMessages(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
sys.puts("testing email "+emails.length); |
|
|
sys.puts("testing email "+emails.length); |
|
@ -62,8 +61,7 @@ sys.puts("test "+emails.length+" emails"); |
|
|
})(); |
|
|
})(); |
|
|
|
|
|
|
|
|
// run good HTTP messages test after previous test ends.
|
|
|
// run good HTTP messages test after previous test ends.
|
|
|
var secondPart = new (events.Promise), |
|
|
var server = http.createServer(function (req, res) { |
|
|
server = http.createServer(function (req, res) { |
|
|
|
|
|
sys.puts("HTTP mp request"); |
|
|
sys.puts("HTTP mp request"); |
|
|
var mp = multipart.parse(req), |
|
|
var mp = multipart.parse(req), |
|
|
curr = 0; |
|
|
curr = 0; |
|
@ -94,13 +92,13 @@ var secondPart = new (events.Promise), |
|
|
server.listen(PORT); |
|
|
server.listen(PORT); |
|
|
|
|
|
|
|
|
// could dry these two up a bit.
|
|
|
// could dry these two up a bit.
|
|
|
firstPart.addCallback(function testGoodMessages () { |
|
|
function testGoodMessages () { |
|
|
var httpMessages = fixture.messages.slice(0); |
|
|
var httpMessages = fixture.messages.slice(0); |
|
|
sys.puts("testing "+httpMessages.length+" good messages"); |
|
|
sys.puts("testing "+httpMessages.length+" good messages"); |
|
|
(function testHTTP () { |
|
|
(function testHTTP () { |
|
|
message = httpMessages.pop(); |
|
|
message = httpMessages.pop(); |
|
|
if (!message) { |
|
|
if (!message) { |
|
|
secondPart.emitSuccess(); |
|
|
testBadMessages(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
sys.puts("test message "+httpMessages.length); |
|
|
sys.puts("test message "+httpMessages.length); |
|
@ -116,8 +114,9 @@ firstPart.addCallback(function testGoodMessages () { |
|
|
}); |
|
|
}); |
|
|
req.close(); |
|
|
req.close(); |
|
|
})(); |
|
|
})(); |
|
|
}); |
|
|
} |
|
|
secondPart.addCallback(function testBadMessages () { |
|
|
|
|
|
|
|
|
function testBadMessages () { |
|
|
var httpMessages = fixture.badMessages.slice(0); |
|
|
var httpMessages = fixture.badMessages.slice(0); |
|
|
sys.puts("testing "+httpMessages.length+" bad messages"); |
|
|
sys.puts("testing "+httpMessages.length+" bad messages"); |
|
|
(function testHTTP () { |
|
|
(function testHTTP () { |
|
@ -139,4 +138,4 @@ secondPart.addCallback(function testBadMessages () { |
|
|
}); |
|
|
}); |
|
|
req.close(); |
|
|
req.close(); |
|
|
})(); |
|
|
})(); |
|
|
}); |
|
|
} |
|
|