Permalink
Browse files

Added basic tests.

  • Loading branch information...
1 parent 2d18f84 commit e06f8afa4680e452fd9c1a8a54acecbe2de44fcb @mikl committed Sep 6, 2012
Showing with 40 additions and 2 deletions.
  1. +4 −0 .travis.yml
  2. +2 −1 README.md
  3. +2 −1 package.json
  4. +32 −0 test/mischief-test.js
View
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
View
@@ -1,3 +1,5 @@
+[![build status](https://secure.travis-ci.org/mikl/node-chaos-monkeyware.png)](http://travis-ci.org/mikl/node-chaos-monkeyware)
+
Chaos Monkeyware
================
@@ -45,7 +47,6 @@ It is used as any other Connect/Express compatible middleware.
var app = require('connect')()
.use(connect.logger('dev'))
- .use(connect.static('public'))
.use(require('chaos-monkeyware')())
.use(function(req, res){
res.end('hello world\n');
View
@@ -1,6 +1,6 @@
{
"name": "chaos-monkeyware",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "Chaos Monkey implemented as Node.js Express-compatible middleware.",
"author": "Mikkel Hoegh <mikkel@hoegh.org> (http://mikkel.hoegh.org/)",
"main": "index.js",
@@ -26,6 +26,7 @@
"connect": "2.4.x",
"express": "3.0.x",
"flatiron": "0.2.x",
+ "request": "2.11.x",
"restify": "1.4.x",
"vows": "0.6.x"
},
View
@@ -0,0 +1,32 @@
+// Tests for mischief.
+"use strict";
+
+var assert = require('assert'),
+ connect = require('connect'),
+ mischief = require('../mischief'),
+ request = require('request'),
+ vows = require('vows');
+
+vows.describe('Chaos Monkeyware mischief').addBatch({
+ "when HTTP 500 mischief is active on a connect server,": {
+ topic: function () {
+ var callback = this.callback();
+
+ var app = connect()
+ .use(connect.logger('dev'))
+ .use(mischief.http500)
+ .use(function(req, res){
+ res.end('hello world\n');
+ })
+ .listen(34526, '127.0.0.1', 511, function (err) {
+ callback(err, app);
+ });
+ },
+
+ 'HTTP requests will fail every time.': function (app) {
+ request('http://127.0.0.1:34526', function (error, response, body) {
+ assert.equal(response.statusCode, 500);
+ });
+ },
+ },
+}).export(module);

0 comments on commit e06f8af

Please sign in to comment.