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

Function TEST

valdi/test/runtime/Tweaks_tests.cpp:41–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39} // namespace
40
41TEST(RuntimeTweaks, tsnPerModuleSetting) {
42 auto provider = makeShared<TestTweakValueProvider>();
43 auto tweaks = makeShared<ValdiRuntimeTweaks>(provider.toShared());
44
45 // not configured - always true
46 ASSERT_TRUE(tweaks->enableTSNForModule(STRING_LITERAL("valdi_core")));
47 ASSERT_TRUE(tweaks->enableTSNForModule(STRING_LITERAL("add_friends")));
48
49 // create config for valdi_core
50 Valdi::TsnConfig tsnConfig;
51 tsnConfig.add_enabled_modules("valdi_core");
52
53 auto len = tsnConfig.ByteSizeLong();
54 std::vector<uint8_t> buffer(len);
55 bool success = tsnConfig.SerializeToArray(buffer.data(), static_cast<int>(buffer.size()));
56 ASSERT_TRUE(success);
57
58 auto bytes = makeShared<Bytes>();
59 bytes->assignVec(std::move(buffer));
60 auto arrayValue = Value(makeShared<ValueTypedArray>(TypedArrayType::Uint8Array, Valdi::BytesView(bytes)));
61
62 auto config = makeShared<ValueMap>();
63 (*config)[STRING_LITERAL("VALDI_TSN_ENABLED_MODULES")] = arrayValue;
64
65 // test only valdi_core is enabled
66 provider->config = Value(config);
67 ASSERT_TRUE(tweaks->enableTSNForModule(STRING_LITERAL("valdi_core")));
68 ASSERT_FALSE(tweaks->enableTSNForModule(STRING_LITERAL("add_friends")));
69}
70
71TEST(RuntimeTweaks, moduleLoadDiagnosticsSetting) {
72 auto provider = makeShared<TestTweakValueProvider>();

Callers

nothing calls this directly

Calls 9

toSharedMethod · 0.80
add_enabled_modulesMethod · 0.80
assignVecMethod · 0.80
ValueInterface · 0.50
BytesViewClass · 0.50
enableTSNForModuleMethod · 0.45
ByteSizeLongMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected