Skip to content

Commit

Permalink
[configuration] default to fake backend
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Oct 19, 2017
1 parent e5284e1 commit f86d015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apicast/src/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ local function readonly_table(table)
end

local empty_t = readonly_table()
local fake_backend = readonly_table({ endpoint = 'http://127.0.0.1:8081' })

local function backend_endpoint(proxy)
local backend_endpoint_override = resty_url.parse(env.get("BACKEND_ENDPOINT_OVERRIDE"))
Expand All @@ -144,7 +145,7 @@ local function backend_endpoint(proxy)
if test_nginx_server_port then
return { endpoint = 'http://127.0.0.1:' .. test_nginx_server_port }
else
return nil
return fake_backend
end
else
return { endpoint = backend.endpoint or tostring(backend), host = backend.host }
Expand Down
5 changes: 3 additions & 2 deletions spec/configuration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ describe('Configuration object', function()
end)

describe('backend', function()
it('defaults to nothing', function()
it('defaults to fake backend', function()
local config = configuration.parse_service({ proxy = {
backend = nil
}})

assert.falsy(config.backend)
assert.same('http://127.0.0.1:8081', config.backend.endpoint)
assert.falsy(config.backend.host)
end)

it('is overriden from ENV', function()
Expand Down

0 comments on commit f86d015

Please sign in to comment.