Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix(galileo) proper empty encoding as empty arr #1909

Merged
merged 1 commit into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions kong/plugins/galileo/alf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ local function hash_to_array(t)
arr[#arr+1] = {name = k, value = v}
end
end

-- FIXME: temporary workardound
-- remove once https://github.com/openresty/lua-cjson/pull/16
-- is included in a formal OpenResty release.
if #arr == 0 then
return cjson.empty_array
end

return arr
end

Expand Down
18 changes: 18 additions & 0 deletions spec/03-plugins/05-galileo/01-alf_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ local alf_serializer = require "kong.plugins.galileo.alf"
-- input sets to the serializer.
local function reload_alf_serializer()
package.loaded["kong.plugins.galileo.alf"] = nil

-- FIXME: temporary double-loading of the cjson module
-- for the encoding JSON as empty array tests in the
-- serialize() suite.
-- remove once https://github.com/openresty/lua-cjson/pull/16
-- is included in a formal OpenResty release.
package.loaded["cjson"] = nil
package.loaded["cjson.safe"] = nil
require "cjson.safe"
require "cjson"

alf_serializer = require "kong.plugins.galileo.alf"
end

Expand Down Expand Up @@ -487,6 +498,13 @@ describe("ALF serializer", function()
end) -- add_entry()

describe("serialize()", function()
-- FIXME: temporary double-loading of the cjson module
-- for the encoding JSON as empty array tests in the
-- serialize() suite.
-- remove once https://github.com/openresty/lua-cjson/pull/16
-- is included in a formal OpenResty release.
reload_alf_serializer()

local cjson = require "cjson.safe"
it("returns a JSON encoded ALF object", function()
local alf = alf_serializer.new()
Expand Down