Permalink
Browse files

web connect test that fails

  • Loading branch information...
1 parent f2aecdd commit 6eeef0ab8bb910ca386795f51e113567c0afbcbb @substack committed Sep 15, 2010
Showing with 36 additions and 0 deletions.
  1. +36 −0 test/web.js
View
@@ -0,0 +1,36 @@
+var Cart = require('cart');
+var connect = require('connect');
+var http = require('http');
+
+exports.webserver = function (assert) {
+ var port = Math.floor(Math.random() * 40000 + 10000);
+
+ var server = connect.createServer();
+ server.use(connect.cookieDecoder());
+ //*
+ server.use(connect.session({
+ store : new Cart({ dbFile : '/tmp/cart-' + port + '.db' }),
+ secret : 'meowmers',
+ }));
+ //*/
+ server.use(connect.router(function (app) {
+ app.get('/', function (req, res) {
+ res.writeHead(200, { 'Content-Type' : 'text/html' });
+ res.write('catface');
+ res.end();
+ });
+ }));
+ server.listen(port, 'localhost');
+
+ {
+ var client = http.createClient(port);
+ var req = client.request('GET', '/', { host : 'localhost' });
+ req.end();
+ req.on('response', function (res) {
+ res.on('data', function (data) {
+ assert.equal('catface', data.toString());
+ });
+ server.close();
+ });
+ }
+};

0 comments on commit 6eeef0a

Please sign in to comment.