From 2100324ec2ed6b2b0770f8954f1dd1c02484f2cf Mon Sep 17 00:00:00 2001 From: William Boman Date: Wed, 4 Jan 2023 07:28:35 +0100 Subject: feat(registry): add has_package() method (#847) --- tests/mason-registry/registry_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/mason-registry/registry_spec.lua (limited to 'tests') diff --git a/tests/mason-registry/registry_spec.lua b/tests/mason-registry/registry_spec.lua new file mode 100644 index 00000000..5931ca35 --- /dev/null +++ b/tests/mason-registry/registry_spec.lua @@ -0,0 +1,20 @@ +local Pkg = require "mason-core.package" +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) +end) -- cgit v1.2.3-70-g09d2