Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mayorova committed Apr 3, 2018
1 parent c353d01 commit 65f52d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
22 changes: 22 additions & 0 deletions spec/balancer_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local apicast_balancer = require 'apicast.balancer'
local resty_balancer = require 'resty.balancer'

describe('apicast.balancer', function()

describe('.call', function()
local b = resty_balancer.new(function(peers) return peers[1] end)
b.peers = function() return { { '127.0.0.2' } } end
b.balancer = { }

ngx.var = {
proxy_host = 'upstream',
proxy_pass = 'https://example.com'
}

it('returns peers from servers', function()
b.balancer.set_current_peer = spy.new(function() return true end)
apicast_balancer:call(_,b)
assert.spy(b.balancer.set_current_peer).was.called_with('127.0.0.2', 443)
end)
end)
end)
13 changes: 0 additions & 13 deletions spec/resty/balancer_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,6 @@ describe('resty.balancer', function()
assert.truthy(ok)
assert.spy(b.balancer.set_current_peer).was.called_with('127.0.0.2', 8091)
end)

it('works with default port', function()
local peers = {
{ '127.0.0.2' }
}
b.balancer.set_current_peer = spy.new(function() return true end)

local ok, err = b:set_peer(peers, 443)

assert.falsy(err)
assert.truthy(ok)
assert.spy(b.balancer.set_current_peer).was.called_with('127.0.0.2', 443)
end)
end)

describe('round-robin balancer', function()
Expand Down

0 comments on commit 65f52d9

Please sign in to comment.