# HG changeset patch # User Matthew Wild # Date 1665257581 -3600 # Node ID 2eb02b32bb4ca7ac960d3e7e830efc1e147abf61 # Parent 9ef8f248635c37f1cfe9dc1af8469518aa309930 util.roles: Add some more missing test cases Found via mutation testing. diff -r 9ef8f248635c -r 2eb02b32bb4c spec/util_roles_spec.lua --- a/spec/util_roles_spec.lua Fri Oct 07 18:04:30 2022 +0100 +++ b/spec/util_roles_spec.lua Sat Oct 08 20:33:01 2022 +0100 @@ -11,6 +11,24 @@ assert.is_truthy(roles.is_role(test_role)); end); describe("role object", function () + it("can be initialized with permissions", function () + local test_role_2 = roles.new({ + permissions = { + perm1 = true; + perm2 = false; + }; + }); + assert.truthy(test_role_2:may("perm1")); + assert.falsy(test_role_2:may("perm2")); + end); + it("has a sensible tostring", function () + local test_role_2 = roles.new({ + id = "test-role-2"; + name = "Test Role 2"; + }); + assert.truthy(tostring(test_role_2):find("test-role-2", 1, true)); + assert.truthy(tostring(test_role_2):find("Test Role 2", 1, true)); + end); it("is restrictive by default", function () assert.falsy(test_role:may("my-permission")); end);