Skip to content

Commit

Permalink
httpc: update client error message
Browse files Browse the repository at this point in the history
Previously Tarantool used to raise the confusing error message in
case of invalid usage of the httpc module. Fixed to follow the
current module API.

Closes #4136
  • Loading branch information
kshcherbatov authored and kyukhin committed Apr 23, 2019
1 parent 3eac590 commit 5ebf933
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lua/httpc.lua
Expand Up @@ -294,7 +294,7 @@ curl_mt = {
--
request = function(self, method, url, body, opts)
if not method or not url then
error('request(method, url [, options]])')
error('request(method, url[, body, [options]])')
end
local resp = self.curl:request(method, url, body, opts or {})
if resp and resp.headers then
Expand Down
8 changes: 7 additions & 1 deletion test/app-tap/http_client.test.lua
Expand Up @@ -62,7 +62,13 @@ local function stop_server(test, server)
end

local function test_http_client(test, url, opts)
test:plan(10)
test:plan(11)

-- gh-4136: confusing httpc usage error message
local ok, err = pcall(client.request, client)
local usage_err = "request(method, url[, body, [options]])"
test:is_deeply({ok, err:split(': ')[2]}, {false, usage_err},
"test httpc usage error")

test:isnil(rawget(_G, 'http'), "global namespace is not polluted");
test:isnil(rawget(_G, 'http.client'), "global namespace is not polluted");
Expand Down

0 comments on commit 5ebf933

Please sign in to comment.