From 39f84cd24fac6284212909b391df85297019a09e Mon Sep 17 00:00:00 2001 From: William Boman Date: Tue, 12 Apr 2022 23:41:12 +0200 Subject: feat(fetch): add ability to download file instead of writing to stdout --- tests/core/fetch_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/core/fetch_spec.lua') 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) -- cgit v1.2.3-70-g09d2