Skip to content

Commit

Permalink
Merge pull request Kong#2404 from Mashape/fix/upstream-schema
Browse files Browse the repository at this point in the history
fix(upstream) proper primary_key in kong schema
  • Loading branch information
thibaultcha authored Apr 25, 2017
2 parents e3e35ed + 13167c3 commit c00b142
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion kong/dao/schemas/upstreams.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local SLOTS_MSG = "number of slots must be between "..SLOTS_MIN.." and "..SLOTS_

return {
table = "upstreams",
primary_key = {"id", "name"},
primary_key = {"id"},
fields = {
id = {
type = "id",
Expand Down
23 changes: 12 additions & 11 deletions spec/02-integration/03-admin_api/08-upstreams_routes_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local helpers = require "spec.helpers"
local dao_helpers = require "spec.02-integration.02-dao.helpers"
local cjson = require "cjson"
local DAOFactory = require "kong.dao.factory"

local slots_default, slots_max = 100, 2^16

Expand Down Expand Up @@ -36,26 +37,26 @@ dao_helpers.for_each_dao(function(kong_config)

describe("Admin API", function()
local client
local config_db
local dao

setup(function()
config_db = helpers.test_conf.database
helpers.test_conf.database = kong_config.database
dao = assert(DAOFactory.new(kong_config))

assert(helpers.start_kong())
assert(helpers.start_kong{
database = kong_config.database
})
client = assert(helpers.admin_client())
end)

teardown(function()
helpers.test_conf.database = config_db
if client then client:close() end
helpers.stop_kong()
end)

describe("/upstreams " .. kong_config.database, function()
describe("POST", function()
before_each(function()
helpers.dao:truncate_tables()
dao:truncate_tables()
end)
it_content_types("creates an upstream with defaults", function(content_type)
return function()
Expand Down Expand Up @@ -266,7 +267,7 @@ if content_type == "application/x-www-form-urlencoded" then return end

describe("PUT", function()
before_each(function()
helpers.dao:truncate_tables()
dao:truncate_tables()
end)

it_content_types("creates if not exists", function(content_type)
Expand Down Expand Up @@ -388,16 +389,16 @@ if content_type == "application/x-www-form-urlencoded" then return end

describe("GET", function()
setup(function()
helpers.dao:truncate_tables()
dao:truncate_tables()

for i = 1, 10 do
assert(helpers.dao.upstreams:insert {
assert(dao.upstreams:insert {
name = "upstream-"..i,
})
end
end)
teardown(function()
helpers.dao:truncate_tables()
dao:truncate_tables()
end)

it("retrieves the first page", function()
Expand Down Expand Up @@ -463,7 +464,7 @@ if content_type == "application/x-www-form-urlencoded" then return end

describe("empty results", function()
setup(function()
helpers.dao:truncate_tables()
dao:truncate_tables()
end)

it("data property is an empty array", function()
Expand Down

0 comments on commit c00b142

Please sign in to comment.