Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 462e35f23b4a37fa3af68c717228c282cc584781 1 parent 4c73370
@technoweenie authored
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)
}
Please sign in to comment.
Something went wrong with that request. Please try again.