aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-12 23:41:12 +0200
committerWilliam Boman <william@redwill.se>2022-04-12 23:41:27 +0200
commit39f84cd24fac6284212909b391df85297019a09e (patch)
tree1c18de8d8bc43dcb793101cd4ebc0e4353f66bdb /tests
parentadd clarity_lsp (#594) (diff)
downloadmason-39f84cd24fac6284212909b391df85297019a09e.tar
mason-39f84cd24fac6284212909b391df85297019a09e.tar.gz
mason-39f84cd24fac6284212909b391df85297019a09e.tar.bz2
mason-39f84cd24fac6284212909b391df85297019a09e.tar.lz
mason-39f84cd24fac6284212909b391df85297019a09e.tar.xz
mason-39f84cd24fac6284212909b391df85297019a09e.tar.zst
mason-39f84cd24fac6284212909b391df85297019a09e.zip
feat(fetch): add ability to download file instead of writing to stdout
Diffstat (limited to 'tests')
-rw-r--r--tests/core/fetch_spec.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/core/fetch_spec.lua b/tests/core/fetch_spec.lua
index dac7c7b8..b4929167 100644
--- a/tests/core/fetch_spec.lua
+++ b/tests/core/fetch_spec.lua
@@ -29,6 +29,7 @@ describe("fetch", function()
assert.spy(spawn.curl).was_called_with {
{ "-H", "User-Agent: nvim-lsp-installer (+https://github.com/williamboman/nvim-lsp-installer)" },
"-fsSL",
+ vim.NIL,
"https://api.github.com",
}
end)
@@ -46,4 +47,33 @@ describe("fetch", function()
assert.equals([[{"data": "here"}]], result:get_or_throw())
end)
)
+
+ it(
+ "should respect out_file opt",
+ async_test(function()
+ stub(spawn, "wget")
+ stub(spawn, "curl")
+ spawn.wget.returns(Result.failure "wget failure")
+ spawn.curl.returns(Result.failure "curl failure")
+ fetch("https://api.github.com/data", { out_file = "/test.json" })
+
+ assert.spy(spawn.wget).was_called_with {
+ {
+ "--header",
+ "User-Agent: nvim-lsp-installer (+https://github.com/williamboman/nvim-lsp-installer)",
+ },
+ "-nv",
+ "-O",
+ "/test.json",
+ "https://api.github.com/data",
+ }
+
+ assert.spy(spawn.curl).was_called_with {
+ { "-H", "User-Agent: nvim-lsp-installer (+https://github.com/williamboman/nvim-lsp-installer)" },
+ "-fsSL",
+ { "-o", "/test.json" },
+ "https://api.github.com/data",
+ }
+ end)
+ )
end)