Skip to content

Commit

Permalink
fix(test): fix cache tests (Kong#2049)
Browse files Browse the repository at this point in the history
The test api was inserted after Kong was started, and hence gave a 404.
  • Loading branch information
Tieske authored Feb 7, 2017
1 parent 189628b commit c192634
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions spec/02-integration/03-admin_api/05-cache_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ local function do_it(desc, func)
end

describe("Admin API", function()
local client, proxy_client
local api_client, proxy_client
setup(function()
assert(helpers.dao.apis:insert {
name = "api-cache",
hosts = { "cache.com" },
upstream_url = "http://mockbin.com"
})
assert(helpers.start_kong({
custom_plugins = "first-request",
lua_package_path = "?/init.lua;./kong/?.lua;./spec/fixtures/?.lua"
}))
client = helpers.admin_client()
api_client = helpers.admin_client()
proxy_client = helpers.proxy_client(2000)
end)
teardown(function()
if client then
client:close()
if api_client then
api_client:close()
proxy_client:close()
end
helpers.stop_kong()
end)

describe("/cache/{key}", function()
setup(function()
assert(helpers.dao.apis:insert {
name = "api-cache",
hosts = { "cache.com" },
upstream_url = "http://mockbin.com"
})
local res = assert(client:send {
local res = assert(api_client:send {
method = "POST",
path = "/apis/api-cache/plugins/",
headers = {
Expand All @@ -53,7 +53,7 @@ describe("Admin API", function()

describe("GET", function()
do_it("returns 404 if not found", function()
local res = assert(client:send {
local res = assert(api_client:send {
method = "GET",
path = "/cache/_inexistent_",
query = { cache = current_cache },
Expand All @@ -70,7 +70,7 @@ describe("Admin API", function()
})
assert.response(res).has.status(200)

res = assert(client:send {
res = assert(api_client:send {
method = "GET",
path = "/cache/requested",
query = { cache = current_cache },
Expand All @@ -96,22 +96,22 @@ describe("Admin API", function()
})
assert.response(res).has.status(200)

res = assert(client:send {
res = assert(api_client:send {
method = "GET",
path = "/cache/requested",
query = { cache = current_cache },
})
assert.response(res).has.status(200)

-- delete cache
res = assert(client:send {
res = assert(api_client:send {
method = "DELETE",
path = "/cache/requested",
query = { cache = current_cache },
})
assert.response(res).has.status(204)

res = assert(client:send {
res = assert(api_client:send {
method = "GET",
path = "/cache/requested",
query = { cache = current_cache },
Expand All @@ -132,22 +132,22 @@ describe("Admin API", function()
})
assert.response(res).has.status(200)

res = assert(client:send {
res = assert(api_client:send {
method = "GET",
path = "/cache/requested",
query = { cache = current_cache },
})
assert.response(res).has.status(200)

-- delete cache
res = assert(client:send {
res = assert(api_client:send {
method = "DELETE",
path = "/cache",
query = { cache = current_cache },
})
assert.response(res).has.status(204)

res = assert(client:send {
res = assert(api_client:send {
method = "GET",
path = "/cache/requested",
query = { cache = current_cache },
Expand Down

0 comments on commit c192634

Please sign in to comment.