| 37 | }; |
| 38 | |
| 39 | TEST(PersistentStoreModuleFactory, createsNewStoreIfDeallocate) { |
| 40 | PersistentStoreDependencies dependencies; |
| 41 | |
| 42 | auto userSession = Valdi::makeShared<UserSession>(STRING_LITERAL("4242")); |
| 43 | SharedAtomicObject<UserSession> sharedUserSession; |
| 44 | sharedUserSession.set(userSession); |
| 45 | |
| 46 | auto storeFactory = Valdi::makeShared<PersistentStoreModuleFactory>(dependencies.diskCache, |
| 47 | dependencies.dispatchQueue, |
| 48 | sharedUserSession, |
| 49 | dependencies.keyChain, |
| 50 | dependencies.logger, |
| 51 | dependencies.disableDecryptionByDefault); |
| 52 | |
| 53 | Path rootPath("wut"); |
| 54 | |
| 55 | auto storePath = StringCache::getGlobal().makeString(rootPath.appending("stuff").toString()); |
| 56 | |
| 57 | auto store = storeFactory->getOrCreatePersistentStore(storePath, userSession, 5, true, true); |
| 58 | dependencies.dispatchQueue->sync([]() {}); |
| 59 | Weak<PersistentStore> weakStore = store; |
| 60 | |
| 61 | store = nullptr; |
| 62 | store = storeFactory->getOrCreatePersistentStore(storePath, userSession, 5, true, true); |
| 63 | dependencies.dispatchQueue->sync([]() {}); |
| 64 | |
| 65 | ASSERT_NE(store, nullptr); |
| 66 | ASSERT_EQ(weakStore.use_count(), 0); |
| 67 | ASSERT_FALSE(weakStore.lock()); |
| 68 | ASSERT_NE(weakStore.lock(), store); |
| 69 | } |
| 70 | |
| 71 | TEST(PersistentStoreModuleFactory, reusesStoreWithSamePath) { |
| 72 | PersistentStoreDependencies dependencies; |
nothing calls this directly
no test coverage detected