Skip to main content

GroupTestUtils

Helpers for injecting group membership onto a PlayerMock in tests.

GroupUtils answers rank and role from two engine calls -- GetRolesInGroupAsync (primary) and GetGroupsAsync (fallback) -- and only those calls are intercepted for mocks, so its parsing and fallback logic runs for real in tests. GroupTestUtils.assignGroupInfo writes both injected results from one rank/role pair so the answer is coherent whichever path production code takes.

Functions

assignGroupInfo

GroupTestUtils.assignGroupInfo(
playerPlayer,--

must be a PlayerMock

groupIdnumber,
groupInfo{
ranknumber,
rolestring
}
) → ()

Injects membership in a group for a mock at both engine calls GroupUtils reads, replacing any earlier assignment for the same group. Assign multiple groups by calling once per group.

GroupTestUtils.assignGroupInfo(playerMock, 372, { rank = 230, role = "Admin" })
-- GroupUtils.promiseRankInGroup(playerMock, 372) resolves 230,
-- promiseRoleInGroup(playerMock, 372) resolves "Admin"
Show raw api
{
    "functions": [
        {
            "name": "assignGroupInfo",
            "desc": "Injects membership in a group for a mock at both engine calls [GroupUtils] reads, replacing\nany earlier assignment for the same group. Assign multiple groups by calling once per group.\n\n```lua\nGroupTestUtils.assignGroupInfo(playerMock, 372, { rank = 230, role = \"Admin\" })\n-- GroupUtils.promiseRankInGroup(playerMock, 372) resolves 230,\n-- promiseRoleInGroup(playerMock, 372) resolves \"Admin\"\n```",
            "params": [
                {
                    "name": "player",
                    "desc": "must be a PlayerMock",
                    "lua_type": "Player"
                },
                {
                    "name": "groupId",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "groupInfo",
                    "desc": "",
                    "lua_type": "{ rank: number, role: string }"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 39,
                "path": "src/grouputils/src/Shared/GroupTestUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "GroupTestUtils",
    "desc": "Helpers for injecting group membership onto a [PlayerMock] in tests.\n\n[GroupUtils] answers rank and role from two engine calls -- `GetRolesInGroupAsync`\n(primary) and `GetGroupsAsync` (fallback) -- and only those calls are intercepted for\nmocks, so its parsing and fallback logic runs for real in tests. [GroupTestUtils.assignGroupInfo]\nwrites both injected results from one rank/role pair so the answer is coherent whichever\npath production code takes.",
    "source": {
        "line": 13,
        "path": "src/grouputils/src/Shared/GroupTestUtils.lua"
    }
}