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

Fix curl url reuse #602

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lua/plenary/curl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ end
-- Main ----------------------------------------------------
------------------------------------------------------------
return (function()
local spec = {}
local partial = function(method)
return function(url, opts)
local spec = {}
opts = opts or {}
if type(url) == "table" then
opts = url
Expand Down
18 changes: 17 additions & 1 deletion tests/plenary/curl_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,26 @@ describe("CURL Wrapper:", function()
end)
end)

describe("DEPUG", function() --------------------------------------------------
describe("DEBUG", function() --------------------------------------------------
it("dry_run return the curl command to be ran.", function()
local res = curl.delete("https://jsonplaceholder.typicode.com/posts/8", { dry_run = true })
assert(type(res) == "table")
end)
end)

describe("Issue #601", function() --------------------------------------------
it("should not use URL from previous call", function()
local url = "https://example.com"
local opts = { dry_run = true, dump = "" } -- dump would be random each time
local first = curl.get(url, opts)
eq(table.remove(first, #first), url, "expected url last")

local success, second = pcall(curl.get, opts)
if success then
eq(first, second, "should be same, but without url")
else
-- Failure is also acceptable
end
end)
end)
end)
Loading