Skip to content

Commit

Permalink
test that ternary apps can route to both hit and miss apps
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Apr 19, 2010
1 parent 4c73370 commit 462e35f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions 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.