Skip to content

Commit

Permalink
Implementing a test that will check that the Kong version hardcoded i…
Browse files Browse the repository at this point in the history
…n the constants file is the same as the one in the rockspec file
  • Loading branch information
subnetmarco committed Mar 5, 2015
1 parent 7d5d429 commit ae84a6c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
29 changes: 29 additions & 0 deletions spec/unit/utils_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
local utils = require "kong.tools.utils"
local constants = require "kong.constants"
local cjson = require "cjson"
local stringy = require "stringy"
local rex = require "rex_pcre"
require "lfs"

describe("Version #version", function()

it("should match the right version", function()
local rockspec_path

This comment has been minimized.

Copy link
@Jeevareesha

This comment has been minimized.

Copy link
@subnetmarco

subnetmarco Feb 18, 2019

Author Member
for filename in lfs.dir("./") do
if stringy.endswith(filename, "rockspec") then
rockspec_path = "./"..filename
break
end
end

if not rockspec_path then
error("Can't find the rockspec file")
end

local file_content = utils.read_file(rockspec_path)

local iterator = rex.gmatch(file_content, "version\\s*=\\s*\"([A-Za-z0-9\\.\\-]+)\"")
local m = iterator()

assert.are.same(m, constants.VERSION)
end)

end)

describe("Utils #utils", function()

Expand Down
4 changes: 2 additions & 2 deletions src/kong/constants.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
return {
VERSION = "0.0.1-beta",
VERSION = "0.0.1beta-1",
DATABASE_NULL_ID = "00000000-0000-0000-0000-000000000000",
DATABASE_ERROR_TYPES = {
SCHEMA = "schema",
Expand All @@ -9,7 +9,7 @@ return {
FOREIGN = "foreign"
},
HEADERS = {
VERSION = "X-Kong-Version",
SERVER = "Server",

This comment has been minimized.

Copy link
@thibaultcha

thibaultcha Mar 5, 2015

Member

Why not sending the version anymore @thefosk?

This comment has been minimized.

Copy link
@subnetmarco

subnetmarco Mar 5, 2015

Author Member

We are still sending the version in the Server header.

This comment has been minimized.

Copy link
@thibaultcha

thibaultcha Mar 5, 2015

Member

Oh yeah

PROXY_TIME = "X-Kong-Proxy-Time",
API_TIME = "X-Kong-Api-Time",
ACCOUNT_ID = "X-Account-ID",
Expand Down
2 changes: 1 addition & 1 deletion src/kong/tools/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ end
-- Lapis utils
--
function _M.show_response(status, message, raw)
ngx.header[constants.HEADERS.VERSION] = constants.VERSION
ngx.header[constants.HEADERS.SERVER] = "kong/"..constants.VERSION
ngx.status = status

if raw then
Expand Down

0 comments on commit ae84a6c

Please sign in to comment.