TEST_F(ConfigTests, test_parse) { Config c; auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); for (const auto& pack : packs) { c.addPack(pack.first, "", pack.second); } std::map<std::string, bool> results = { {"unrestricted_pack", true}, {"discovery_pack", false}, {"fake_version_pack", true}, // Although this is a valid discovery query, there is no SQL plugin in // the core tests. {"valid_discovery_pack", false}, {"restricted_pack", true}, }; c.packs(([&results](Pack& pack) { if (results[pack.getName()]) { EXPECT_TRUE(pack.shouldPackExecute()); } else { EXPECT_FALSE(pack.shouldPackExecute()); } })); }
TEST_F(ConfigTests, test_pack_restrictions) { auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); for (const auto& pack : packs) { get().addPack(pack.first, "", pack.second); } std::map<std::string, bool> results = { {"unrestricted_pack", true}, {"discovery_pack", false}, {"fake_version_pack", false}, // Although this is a valid discovery query, there is no SQL plugin in // the core tests. {"valid_discovery_pack", false}, {"restricted_pack", false}, }; get().packs(([&results](std::shared_ptr<Pack>& pack) { if (results[pack->getName()]) { EXPECT_TRUE(pack->shouldPackExecute()) << "Pack " << pack->getName() << " should have executed"; } else { EXPECT_FALSE(pack->shouldPackExecute()) << "Pack " << pack->getName() << " should not have executed"; } })); }
TEST_F(PacksTests, test_restriction_population) { // Require that all potential restrictions are populated before being checked. auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); Pack fpack("fake_pack", packs.get_child("restricted_pack")); ASSERT_FALSE(fpack.getPlatform().empty()); ASSERT_FALSE(fpack.getVersion().empty()); ASSERT_EQ(fpack.getShard(), 1U); }
TEST_F(ConfigTests, test_parse) { Config c; auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); for (const auto& pack : packs) { c.addPack(pack.first, "", pack.second); } for (Pack& p : c.schedule_) { EXPECT_TRUE(p.shouldPackExecute()); } }
TEST_F(PacksTests, test_parse) { auto tree = getExamplePacksConfig(); EXPECT_EQ(tree.count("packs"), 1U); }
/// no discovery queries, no platform restriction, fake version string pt::ptree getPackWithFakeVersion() { auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); return packs.get_child("foobaz"); }
/// 1 discovery query which will always pass pt::ptree getPackWithValidDiscovery() { auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); return packs.get_child("baz"); }
/// no discovery queries, no platform restriction pt::ptree getUnrestrictedPack() { auto tree = getExamplePacksConfig(); auto packs = tree.get_child("packs"); return packs.get_child("kernel"); }
/// no discovery queries, no platform restriction, fake version string JSON getPackWithFakeVersion() { auto doc = getExamplePacksConfig(); return JSON::newFromValue(doc.doc()["packs"]["fake_version_pack"]); }
/// 1 discovery query which will always pass JSON getPackWithValidDiscovery() { auto doc = getExamplePacksConfig(); return JSON::newFromValue(doc.doc()["packs"]["valid_discovery_pack"]); }
// several restrictions (version, platform, shard) JSON getRestrictedPack() { auto doc = getExamplePacksConfig(); return JSON::newFromValue(doc.doc()["packs"]["restricted_pack"]); }