Permalink
Browse files

test that ternary apps can route to both hit and miss apps

  • Loading branch information...
1 parent 4c73370 commit 462e35f23b4a37fa3af68c717228c282cc584781 @technoweenie committed Apr 19, 2010
Showing with 19 additions and 10 deletions.
  1. +19 −10 test/ternary_test.js
View
29 test/ternary_test.js
@@ -1,23 +1,32 @@
var assert = require('assert')
-function loadBalancer( app1 ) {
- return function( app2 ) {
- return function() {
- return app1.call( this );
+function loadBalancer(index) {
+ return function( app1 ) {
+ return function( app2 ) {
+ return function() {
+ return [app1, app2][index].call( this );
+ }
}
}
}
module.exports = (fab = require( "../" ))
(fab.nodejs)
- (loadBalancer)
- ('a')
- ('b')
+ (/\/a/)
+ (loadBalancer(0))
+ ('a')
+ ('b')
+ (/\/b/)
+ (loadBalancer(1))
+ ('a')
+ ('b')
+ (404)
module.exports.request = function(client) {
- return client.request('GET', '/')
+ return [client.request('GET', '/a'), client.request('GET', '/b')]
}
-module.exports.assert = function(resp) {
- assert.equal("a", resp.body)
+module.exports.assert = function(resps) {
+ assert.equal("a", resps[0].body)
+ assert.equal("b", resps[1].body)
}

0 comments on commit 462e35f

Please sign in to comment.