aboutsummaryrefslogtreecommitdiffstats
path: root/tests/platform_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-05-01 16:19:12 +0200
committerGitHub <noreply@github.com>2022-05-01 16:19:12 +0200
commit41ae5494c2cc42a8880b7878f0e0a3853dd503e3 (patch)
treea9cc4210a1eb1ea46334fb56700a69d7e334fd20 /tests/platform_spec.lua
parentfix!(beancount-language-server):update beancount install source (#649) (diff)
downloadmason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.tar
mason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.tar.gz
mason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.tar.bz2
mason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.tar.lz
mason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.tar.xz
mason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.tar.zst
mason-41ae5494c2cc42a8880b7878f0e0a3853dd503e3.zip
feat(platform): add convenience API for detecting OS + arch (#653)
Diffstat (limited to 'tests/platform_spec.lua')
-rw-r--r--tests/platform_spec.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/platform_spec.lua b/tests/platform_spec.lua
index 916b240b..d9d169db 100644
--- a/tests/platform_spec.lua
+++ b/tests/platform_spec.lua
@@ -8,8 +8,11 @@ describe("platform", function()
return require "nvim-lsp-installer.platform"
end
- local function stub_mac()
+ local function stub_mac(arch)
+ arch = arch or "x86_64"
stub(vim.fn, "has")
+ stub(vim.loop, "os_uname")
+ vim.loop.os_uname.returns { machine = arch }
vim.fn.has.on_call_with("mac").returns(1)
vim.fn.has.on_call_with("unix").returns(1)
vim.fn.has.on_call_with(match._).returns(0)
@@ -28,28 +31,47 @@ describe("platform", function()
vim.fn.has.on_call_with(match._).returns(0)
end
+ it("should be able to detect platform and arch", function()
+ stub_mac "arm64"
+ assert.is_true(platform().is.mac_arm64)
+ assert.is_false(platform().is.mac_x64)
+ assert.is_false(platform().is.nothing)
+ end)
+
it("should be able to detect macos", function()
stub_mac()
assert.is_true(platform().is_mac)
+ assert.is_true(platform().is.mac)
assert.is_true(platform().is_unix)
+ assert.is_true(platform().is.unix)
assert.is_false(platform().is_linux)
+ assert.is_false(platform().is.linux)
assert.is_false(platform().is_win)
+ assert.is_false(platform().is.win)
end)
it("should be able to detect linux", function()
stub_linux()
assert.is_false(platform().is_mac)
+ assert.is_false(platform().is.mac)
assert.is_true(platform().is_unix)
+ assert.is_true(platform().is.unix)
assert.is_true(platform().is_linux)
+ assert.is_true(platform().is.linux)
assert.is_false(platform().is_win)
+ assert.is_false(platform().is.win)
end)
it("should be able to detect windows", function()
stub_windows()
assert.is_false(platform().is_mac)
+ assert.is_false(platform().is.mac)
assert.is_false(platform().is_unix)
+ assert.is_false(platform().is.unix)
assert.is_false(platform().is_linux)
+ assert.is_false(platform().is.linux)
assert.is_true(platform().is_win)
+ assert.is_true(platform().is.win)
end)
it("should run correct case on linux", function()