Created
May 21, 2012 13:38
-
-
Save syshen/2762375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('Strategy in round robin', function() { | |
| describe("without proxy setting", function() { | |
| // initiate your testing target, or create your mock objects | |
| var proxy = new lbProxy.LoadBalancingProxy(basic_options); | |
| var strategy = new strategies.RoundRobinStrategy(proxy.proxies, basic_options); | |
| it("should return null", function() { | |
| var proxy = strategy.next(); | |
| should.not.exist(proxy); | |
| }); | |
| }); | |
| describe("with one proxy setting", function() { | |
| basic_options["backends"] = [ | |
| { | |
| host: "127.0.0.1", | |
| port: 8001, | |
| https: false | |
| } | |
| ]; | |
| var proxy = new lbProxy.LoadBalancingProxy(basic_options); | |
| var strategy = new strategies.RoundRobinStrategy(proxy.proxies, basic_options); | |
| it("should always return the first one", function(done) { | |
| strategy(req, res, function(err, p) { | |
| should.not.exist(err); | |
| p.target.host.should.equal('127.0.0.1'); | |
| p.target.port.should.equal(8001); | |
| done(); | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment