MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TEST

Function TEST

valdi/test/runtime/PersistentStoreModuleFactory_tests.cpp:39–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37};
38
39TEST(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
71TEST(PersistentStoreModuleFactory, reusesStoreWithSamePath) {
72 PersistentStoreDependencies dependencies;

Callers

nothing calls this directly

Calls 12

getGlobalFunction · 0.85
makeStringMethod · 0.80
use_countMethod · 0.80
getUserSessionMethod · 0.80
batchWritesDisabledMethod · 0.80
setMethod · 0.65
toStringMethod · 0.65
appendingMethod · 0.45
syncMethod · 0.45
lockMethod · 0.45
getMaxWeightMethod · 0.45

Tested by

no test coverage detected