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
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
Builds a DataStore over mock and owns it with the maid.
newSessionLockedStore
Builds a session-locked DataStore over mock and owns it with the maid.
newMessageHelper
Builds a DataStoreMessageHelper over dataStore and owns it with the maid.