aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-registry/registry_spec.lua
blob: 35c37853056a9495dcde240b07ab5809e820fb0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local Pkg = require "mason-core.package"
local test_helpers = require "mason-test.helpers"
local registry = require "mason-registry"

describe("mason-registry", function()
    it("should return package", function()
        assert.is_true(getmetatable(registry.get_package "dummy").__index == Pkg)
    end)

    it("should error when getting non-existent package", function()
        local err = assert.has_error(function()
            registry.get_package "non-existent"
        end)
        assert.equals([[Cannot find package "non-existent".]], err)
    end)

    it("should check whether package exists", function()
        assert.is_true(registry.has_package "dummy")
        assert.is_false(registry.has_package "non-existent")
    end)

    it("should get all package specs", function()
        assert.equals(3, #registry.get_all_package_specs())
    end)

    it("should check if package is installed", function ()
        local dummy = registry.get_package "dummy"
        assert.is_false(registry.is_installed "dummy")
        test_helpers.sync_install(dummy)
        assert.is_true(registry.is_installed "dummy")
    end)
end)