Skip to content

Commit

Permalink
Multipart test no longer depend on Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Feb 21, 2010
1 parent 5fbc750 commit 7a51184
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/mjsunit/test-multipart.js
Expand Up @@ -17,9 +17,8 @@ var http = require("http"),
};

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.
firstPart = new (events.Promise);

// test streaming messages through directly, as if they were in a file or something.
sys.puts("test "+emails.length+" emails");
Expand All @@ -30,7 +29,7 @@ sys.puts("test "+emails.length+" emails");

if (!email) {
sys.puts("done testing emails");
firstPart.emitSuccess();
testGoodMessages();
return;
}
sys.puts("testing email "+emails.length);
Expand Down Expand Up @@ -62,8 +61,7 @@ sys.puts("test "+emails.length+" emails");
})();

// run good HTTP messages test after previous test ends.
var secondPart = new (events.Promise),
server = http.createServer(function (req, res) {
var server = http.createServer(function (req, res) {
sys.puts("HTTP mp request");
var mp = multipart.parse(req),
curr = 0;
Expand Down Expand Up @@ -94,13 +92,13 @@ var secondPart = new (events.Promise),
server.listen(PORT);

// could dry these two up a bit.
firstPart.addCallback(function testGoodMessages () {
function testGoodMessages () {
var httpMessages = fixture.messages.slice(0);
sys.puts("testing "+httpMessages.length+" good messages");
(function testHTTP () {
message = httpMessages.pop();
if (!message) {
secondPart.emitSuccess();
testBadMessages();
return;
}
sys.puts("test message "+httpMessages.length);
Expand All @@ -116,8 +114,9 @@ firstPart.addCallback(function testGoodMessages () {
});
req.close();
})();
});
secondPart.addCallback(function testBadMessages () {
}

function testBadMessages () {
var httpMessages = fixture.badMessages.slice(0);
sys.puts("testing "+httpMessages.length+" bad messages");
(function testHTTP () {
Expand All @@ -139,4 +138,4 @@ secondPart.addCallback(function testBadMessages () {
});
req.close();
})();
});
}

0 comments on commit 7a51184

Please sign in to comment.