test: beef up checks in test-http-unix-socket.js, add to `make test-uv`
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 20 Jul 2011 22:36:54 +0000 (00:36 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 21 Jul 2011 01:51:23 +0000 (03:51 +0200)
Makefile
test/simple/test-http-unix-socket.js

index 61ffbe3..aaddd6e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -128,6 +128,7 @@ UVTEST += simple/test-http-proxy
 UVTEST += simple/test-http-request-end
 UVTEST += simple/test-http-response-close
 UVTEST += simple/test-http-response-readable
+UVTEST += simple/test-http-unix-socket
 UVTEST += simple/test-http-server
 UVTEST += simple/test-http-server-multiheaders
 UVTEST += simple/test-http-set-cookies
index 2184663..d43f573 100644 (file)
@@ -26,6 +26,10 @@ var http = require('http');
 
 var SOCKET = common.tmpDir + '/http.sock';
 
+var status_ok  = false; // status code == 200?
+var headers_ok = false;
+var body_ok    = false;
+
 var server = http.createServer(function(req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain',
                       'Connection': 'close'
@@ -44,14 +48,21 @@ server.listen(SOCKET, function() {
 
   var req = http.get(options, function(res) {
     assert.equal(res.statusCode, 200);
+    status_ok = true;
+
     assert.equal(res.headers['content-type'], 'text/plain');
+    headers_ok = true;
+
     res.body = '';
     res.setEncoding('utf8');
+
     res.on('data', function (chunk) {
       res.body += chunk;
     });
+
     res.on('end', function() {
       assert.equal(res.body, 'hello world\n');
+      body_ok = true;
       server.close();
     });
   });
@@ -72,7 +83,8 @@ server.on('close', function() {
 });
 
 process.on('exit', function() {
-  try {
-    server.close();
-  } catch (e) {}
+  server.close();
+  assert.ok(status_ok);
+  assert.ok(headers_ok);
+  assert.ok(body_ok);
 });