test.basic.js 580 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Module dependencies.
  3. */
  4. var cluster = require('../')
  5. , http = require('http');
  6. require('./common');
  7. var server = http.createServer(function(req, res){
  8. res.writeHead(200);
  9. res.end('Hello World');
  10. });
  11. cluster = cluster(server)
  12. .listen(3000);
  13. cluster.on('listening', function(){
  14. process.cwd().should.include.string('cluster/test');
  15. http.get({ host: 'localhost', port: 3000 }, function(res){
  16. res.on('data', function(chunk){
  17. chunk.toString().should.equal('Hello World');
  18. });
  19. res.on('end', function(){
  20. cluster.close();
  21. });
  22. });
  23. });