diff options
| author | William Boman <william@redwill.se> | 2022-07-08 18:34:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-08 18:34:38 +0200 |
| commit | 976aa4fbee8a070f362cab6f6ec84e9251a90cf9 (patch) | |
| tree | 5e8d9c9c59444a25c7801b8f39763c4ba6e1f76d /tests/core/fetch_spec.lua | |
| parent | feat: add gotests, gomodifytags, impl (#28) (diff) | |
| download | mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.gz mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.bz2 mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.lz mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.xz mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.tar.zst mason-976aa4fbee8a070f362cab6f6ec84e9251a90cf9.zip | |
refactor: add mason-schemas and mason-core modules (#29)
* refactor: add mason-schemas and move generated filetype map to mason-lspconfig
* refactor: add mason-core module
Diffstat (limited to 'tests/core/fetch_spec.lua')
| -rw-r--r-- | tests/core/fetch_spec.lua | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/tests/core/fetch_spec.lua b/tests/core/fetch_spec.lua deleted file mode 100644 index e2506f89..00000000 --- a/tests/core/fetch_spec.lua +++ /dev/null @@ -1,106 +0,0 @@ -local stub = require "luassert.stub" -local match = require "luassert.match" -local fetch = require "mason.core.fetch" -local spawn = require "mason.core.spawn" -local Result = require "mason.core.result" - -describe("fetch", function() - it( - "should exhaust all candidates", - async_test(function() - stub(spawn, "wget") - stub(spawn, "curl") - spawn.wget.returns(Result.failure "wget failure") - spawn.curl.returns(Result.failure "curl failure") - - local result = fetch("https://api.github.com", { - headers = { ["X-Custom-Header"] = "here" }, - }) - assert.is_true(result:is_failure()) - assert.spy(spawn.wget).was_called(1) - assert.spy(spawn.curl).was_called(1) - assert.spy(spawn.wget).was_called_with { - { - "--header='User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)'", - "--header='X-Custom-Header: here'", - }, - "-nv", - "-O", - "-", - "--method=GET", - vim.NIL, -- body-data - "https://api.github.com", - } - - assert.spy(spawn.curl).was_called_with(match.tbl_containing { - match.same { - { - "-H", - "User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)", - }, - { - "-H", - "X-Custom-Header: here", - }, - }, - "-fsSL", - match.same { "-X", "GET" }, - vim.NIL, -- data - vim.NIL, -- out file - "https://api.github.com", - on_spawn = match.is_function(), - }) - end) - ) - - it( - "should return stdout", - async_test(function() - stub(spawn, "wget") - spawn.wget.returns(Result.success { - stdout = [[{"data": "here"}]], - }) - local result = fetch "https://api.github.com/data" - assert.is_true(result:is_success()) - 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: mason.nvim (+https://github.com/williamboman/mason.nvim)'", - }, - "-nv", - "-O", - "/test.json", - "--method=GET", - vim.NIL, -- body-data - "https://api.github.com/data", - } - - assert.spy(spawn.curl).was_called_with(match.tbl_containing { - match.same { - { - "-H", - "User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)", - }, - }, - "-fsSL", - match.same { "-X", "GET" }, - vim.NIL, -- data - match.same { "-o", "/test.json" }, - "https://api.github.com/data", - on_spawn = match.is_function(), - }) - end) - ) -end) |
