Commit 63678cc1 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰 Committed by Francis Dupont

[#65,!30] Added test that loads and verified trees from yang_configs.h

parent e5b1b5f5
......@@ -202,4 +202,37 @@ TEST(YangReprTest, setTest) {
EXPECT_TRUE(repr.verify(testTree, sess, cerr));
}
/// @brief Tests specified configuration.
///
/// Configuration is set and then verified using YangRepr object.
///
/// @param model name of the model to be verified against
/// @param tree tree to be verified
void sanityCheckConfig(const std::string& model, const YRTree& tree) {
// Get a translator object to play with.
S_Connection conn(new Connection("utils unittests"));
S_Session sess(new Session(conn, SR_DS_CANDIDATE));
// Get it.
YangRepr repr(model);
EXPECT_NO_THROW(repr.set(tree, sess))
<< " for model " << model;
bool result = false;
EXPECT_NO_THROW(result = repr.verify(tree, sess, cerr))
<< " for model " << model;
EXPECT_TRUE(result);
}
// This is test environment sanity check. It verifies that every configuration
// defined in yang_configs.h is sane.
TEST(YangReprTest, verifyConfigs) {
for (auto x : test_configs) {
cout << "Testing tree for model " << x.first << endl;
sanityCheckConfig(x.first, x.second);
}
}
}; // end of anonymous namespace
......@@ -442,6 +442,20 @@ const YRTree designExampleTree = {
"disabled", SR_ENUM_T, true }
};
/// @brief Set of example configurations
const std::map<std::string, YRTree> test_configs =
{
{ exampleModel, exampleTree },
{ testModel, testTree },
{ subnetTwoPoolsModelIetf6, subnetTwoPoolsTreeIetf6 },
{ subnetTimersModel, subnetTimersIetf6 },
{ validModelIetf6, validTreeIetf6 },
{ subnetOptionsModelKeaDhcp4, subnetOptionsTreeKeaDhcp4 },
{ subnetOptionsModelKeaDhcp6, subnetOptionsTreeKeaDhcp6 },
{ designExampleModel, designExampleTree }
};
}; // end of namespace isc::yang::test
}; // end of namespace isc::yang
}; // end of namespace isc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment