Esempio n. 1
0
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());
    }
  }));
}
Esempio n. 2
0
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";
    }
  }));
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
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());
  }
}
Esempio n. 5
0
TEST_F(PacksTests, test_parse) {
  auto tree = getExamplePacksConfig();
  EXPECT_EQ(tree.count("packs"), 1U);
}
Esempio n. 6
0
/// 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");
}
Esempio n. 7
0
/// 1 discovery query which will always pass
pt::ptree getPackWithValidDiscovery() {
  auto tree = getExamplePacksConfig();
  auto packs = tree.get_child("packs");
  return packs.get_child("baz");
}
Esempio n. 8
0
/// no discovery queries, no platform restriction
pt::ptree getUnrestrictedPack() {
  auto tree = getExamplePacksConfig();
  auto packs = tree.get_child("packs");
  return packs.get_child("kernel");
}
Esempio n. 9
0
/// no discovery queries, no platform restriction, fake version string
JSON getPackWithFakeVersion() {
  auto doc = getExamplePacksConfig();
  return JSON::newFromValue(doc.doc()["packs"]["fake_version_pack"]);
}
Esempio n. 10
0
/// 1 discovery query which will always pass
JSON getPackWithValidDiscovery() {
  auto doc = getExamplePacksConfig();
  return JSON::newFromValue(doc.doc()["packs"]["valid_discovery_pack"]);
}
Esempio n. 11
0
// several restrictions (version, platform, shard)
JSON getRestrictedPack() {
  auto doc = getExamplePacksConfig();
  return JSON::newFromValue(doc.doc()["packs"]["restricted_pack"]);
}