Skip to main content

DataStoreTestUtils

Shared setup helpers for the DataStore server specs. The two controller builders -- DataStoreTestUtils.setup (raw DataStores) and DataStoreTestUtils.setupDataStoreManager (a PlayerDataStoreManager) -- each own a [Maid] and register everything they create on it, so a single controller:destroy() tears it all down: the stores, the auto-save loop each starts once loaded, the helpers, the manager, and the service bag.

Functions

setup

DataStoreTestUtils.setup() → {...}

Builds the controller the DataStore specs share: a fresh DataStoreMock, a ServiceBag with an in-process MessagingServiceMock injected (so messaging-enabled stores never touch the real MessagingService), and builder methods that own everything they create on one Maid. destroy() tears it all down. Every builder defaults its key to "player_1"; pass a key to override.

Fields: mock, serviceBag. Builders: newDataStore(key?), newSessionLockedStore(key?, userIdList?), newLockHelper(key?) (returns helper, dataStore), newMessageHelper(dataStore?) (returns helper, dataStore), newServer(opts?) (returns dataStore, helper?; opts = { key?, messaging?, autoCloseOnRequest? }). Helpers: awaitOwn(dataStore) -> boolean (loads and reports whether we own the session).

setupDataStoreManager

DataStoreTestUtils.setupDataStoreManager() → {
...
}

Builds the controller the PlayerDataStoreManager specs share: a session-locked manager wired to a fresh DataStoreMock (keyed user_<userId>), all owned by a Maid. destroy() tears down the manager (and the loaded stores whose auto-save loops it owns) and the service bag.

Fields: manager, mock, serviceBag. Helpers: storeAndAwaitLock() -> boolean -- stores a value on user 1's store and waits for the session-locked load to write the lock envelope.

newServiceBag

DataStoreTestUtils.newServiceBag(
maidMaid,
robloxMessagingServiceMessagingServiceMock?--

injected when provided

) → ServiceBag

Builds a ServiceBag with PlaceMessagingService registered and Init/Start'd, owned by the maid. Pass a Roblox MessagingService mock to inject it into PlaceMessagingService between Init and Start.

newDataStore

DataStoreTestUtils.newDataStore(
maidMaid,
keystring
) → DataStore

Builds a DataStore over mock and owns it with the maid.

newSessionLockedStore

DataStoreTestUtils.newSessionLockedStore(
maidMaid,
keystring,
userIdList{number}?--

defaults to { 1 }

) → DataStore

Builds a session-locked DataStore over mock and owns it with the maid.

newMessageHelper

DataStoreTestUtils.newMessageHelper(
maidMaid,
serviceBagServiceBag,
dataStoreDataStore
) → DataStoreMessageHelper

Builds a DataStoreMessageHelper over dataStore and owns it with the maid.

Show raw api
{
    "functions": [
        {
            "name": "setup",
            "desc": "Builds the controller the DataStore specs share: a fresh [DataStoreMock], a [ServiceBag] with an\nin-process [MessagingServiceMock] injected (so messaging-enabled stores never touch the real\nMessagingService), and builder methods that own everything they create on one Maid. `destroy()`\ntears it all down. Every builder defaults its key to `\"player_1\"`; pass a key to override.\n\nFields: `mock`, `serviceBag`.\nBuilders: `newDataStore(key?)`, `newSessionLockedStore(key?, userIdList?)`, `newLockHelper(key?)`\n(returns `helper, dataStore`), `newMessageHelper(dataStore?)` (returns `helper, dataStore`),\n`newServer(opts?)` (returns `dataStore, helper?`; `opts` = `{ key?, messaging?, autoCloseOnRequest? }`).\nHelpers: `awaitOwn(dataStore)` -> boolean (loads and reports whether we own the session).",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ... }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 40,
                "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
            }
        },
        {
            "name": "setupDataStoreManager",
            "desc": "Builds the controller the [PlayerDataStoreManager] specs share: a session-locked manager wired to\na fresh [DataStoreMock] (keyed `user_<userId>`), all owned by a Maid. `destroy()` tears down the\nmanager (and the loaded stores whose auto-save loops it owns) and the service bag.\n\nFields: `manager`, `mock`, `serviceBag`.\nHelpers: `storeAndAwaitLock()` -> boolean -- stores a value on user 1's store and waits for the\nsession-locked load to write the lock envelope.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ manager: PlayerDataStoreManager, mock: DataStoreMock, ... }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 116,
                "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
            }
        },
        {
            "name": "newServiceBag",
            "desc": "Builds a [ServiceBag] with PlaceMessagingService registered and Init/Start'd, owned by the maid.\nPass a Roblox MessagingService mock to inject it into PlaceMessagingService between Init and Start.",
            "params": [
                {
                    "name": "maid",
                    "desc": "",
                    "lua_type": "Maid"
                },
                {
                    "name": "robloxMessagingService",
                    "desc": "injected when provided",
                    "lua_type": "MessagingServiceMock?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ServiceBag"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 155,
                "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
            }
        },
        {
            "name": "newDataStore",
            "desc": "Builds a [DataStore] over `mock` and owns it with the maid.",
            "params": [
                {
                    "name": "maid",
                    "desc": "",
                    "lua_type": "Maid"
                },
                {
                    "name": "mock",
                    "desc": "",
                    "lua_type": "DataStoreMock"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "DataStore"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 174,
                "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
            }
        },
        {
            "name": "newSessionLockedStore",
            "desc": "Builds a session-locked [DataStore] over `mock` and owns it with the maid.",
            "params": [
                {
                    "name": "maid",
                    "desc": "",
                    "lua_type": "Maid"
                },
                {
                    "name": "mock",
                    "desc": "",
                    "lua_type": "DataStoreMock"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "userIdList",
                    "desc": "defaults to { 1 }",
                    "lua_type": "{ number }?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "DataStore"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 187,
                "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
            }
        },
        {
            "name": "newMessageHelper",
            "desc": "Builds a [DataStoreMessageHelper] over `dataStore` and owns it with the maid.",
            "params": [
                {
                    "name": "maid",
                    "desc": "",
                    "lua_type": "Maid"
                },
                {
                    "name": "serviceBag",
                    "desc": "",
                    "lua_type": "ServiceBag"
                },
                {
                    "name": "dataStore",
                    "desc": "",
                    "lua_type": "DataStore"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "DataStoreMessageHelper"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 202,
                "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "DataStoreTestUtils",
    "desc": "Shared setup helpers for the DataStore server specs. The two controller builders --\n[DataStoreTestUtils.setup] (raw DataStores) and [DataStoreTestUtils.setupDataStoreManager]\n(a [PlayerDataStoreManager]) -- each own a [Maid] and register everything they create on it, so a\nsingle `controller:destroy()` tears it all down: the stores, the auto-save loop each starts once\nloaded, the helpers, the manager, and the service bag.",
    "source": {
        "line": 11,
        "path": "src/datastore/src/Server/DataStoreTestUtils.lua"
    }
}