Commit c85f9765 authored by Razvan Becheriu's avatar Razvan Becheriu

[#1265] fixed comments and added asserts

parent 0d006d31
...@@ -433,6 +433,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { ...@@ -433,6 +433,7 @@ TEST_F(JSONFileBackendTest, jsonFile) {
// Check subnet 1. // Check subnet 1.
auto subnet = subnets->begin(); auto subnet = subnets->begin();
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText());
EXPECT_EQ(24, (*subnet)->get().second); EXPECT_EQ(24, (*subnet)->get().second);
...@@ -445,6 +446,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { ...@@ -445,6 +446,7 @@ TEST_F(JSONFileBackendTest, jsonFile) {
// Check subnet 2. // Check subnet 2.
++subnet; ++subnet;
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.3.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.3.0", (*subnet)->get().first.toText());
EXPECT_EQ(24, (*subnet)->get().second); EXPECT_EQ(24, (*subnet)->get().second);
...@@ -457,6 +459,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { ...@@ -457,6 +459,7 @@ TEST_F(JSONFileBackendTest, jsonFile) {
// And finally check subnet 3. // And finally check subnet 3.
++subnet; ++subnet;
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.4.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.4.0", (*subnet)->get().first.toText());
EXPECT_EQ(24, (*subnet)->get().second); EXPECT_EQ(24, (*subnet)->get().second);
...@@ -506,6 +509,7 @@ TEST_F(JSONFileBackendTest, hashComments) { ...@@ -506,6 +509,7 @@ TEST_F(JSONFileBackendTest, hashComments) {
// Check subnet 1. // Check subnet 1.
auto subnet = subnets->begin(); auto subnet = subnets->begin();
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText());
EXPECT_EQ(22, (*subnet)->get().second); EXPECT_EQ(22, (*subnet)->get().second);
...@@ -556,6 +560,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) { ...@@ -556,6 +560,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) {
// Check subnet 1. // Check subnet 1.
auto subnet = subnets->begin(); auto subnet = subnets->begin();
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText());
EXPECT_EQ(22, (*subnet)->get().second); EXPECT_EQ(22, (*subnet)->get().second);
...@@ -572,7 +577,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) { ...@@ -572,7 +577,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) {
TEST_F(JSONFileBackendTest, cBlockComments) { TEST_F(JSONFileBackendTest, cBlockComments) {
string config_c_block_comments = "/* This is a comment. It should be \n" string config_c_block_comments = "/* This is a comment. It should be \n"
"ignored. Real config starts in line below*/\n" "ignored. Real config starts in line below*/\n"
"{ \"Dhcp4\": {" "{ \"Dhcp4\": {"
"\"interfaces-config\": {" "\"interfaces-config\": {"
" \"interfaces\": [ \"*\" ]" " \"interfaces\": [ \"*\" ]"
...@@ -606,6 +611,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) { ...@@ -606,6 +611,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) {
// Check subnet 1. // Check subnet 1.
auto subnet = subnets->begin(); auto subnet = subnets->begin();
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText());
EXPECT_EQ(22, (*subnet)->get().second); EXPECT_EQ(22, (*subnet)->get().second);
...@@ -656,6 +662,7 @@ TEST_F(JSONFileBackendTest, include) { ...@@ -656,6 +662,7 @@ TEST_F(JSONFileBackendTest, include) {
// Check subnet 1. // Check subnet 1.
auto subnet = subnets->begin(); auto subnet = subnets->begin();
ASSERT_TRUE(subnet != subnets->end());
EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText()); EXPECT_EQ("192.0.2.0", (*subnet)->get().first.toText());
EXPECT_EQ(22, (*subnet)->get().second); EXPECT_EQ(22, (*subnet)->get().second);
......
...@@ -175,6 +175,7 @@ typedef boost::shared_ptr<TestCBControlDHCPv6> TestCBControlDHCPv6Ptr; ...@@ -175,6 +175,7 @@ typedef boost::shared_ptr<TestCBControlDHCPv6> TestCBControlDHCPv6Ptr;
/// @c CBControlDHCPv6 object. /// @c CBControlDHCPv6 object.
class NakedControlledDhcpv6Srv: public ControlledDhcpv6Srv { class NakedControlledDhcpv6Srv: public ControlledDhcpv6Srv {
public: public:
/// @brief Constructor. /// @brief Constructor.
NakedControlledDhcpv6Srv() NakedControlledDhcpv6Srv()
: ControlledDhcpv6Srv(0) { : ControlledDhcpv6Srv(0) {
...@@ -399,6 +400,7 @@ TEST_F(JSONFileBackendTest, jsonFile) { ...@@ -399,6 +400,7 @@ TEST_F(JSONFileBackendTest, jsonFile) {
" } ]," " } ],"
"\"valid-lifetime\": 4000 }" "\"valid-lifetime\": 4000 }"
"}"; "}";
writeFile(TEST_FILE, config); writeFile(TEST_FILE, config);
// Now initialize the server // Now initialize the server
...@@ -416,7 +418,6 @@ TEST_F(JSONFileBackendTest, jsonFile) { ...@@ -416,7 +418,6 @@ TEST_F(JSONFileBackendTest, jsonFile) {
ASSERT_TRUE(subnets); ASSERT_TRUE(subnets);
ASSERT_EQ(3, subnets->size()); // We expect 3 subnets. ASSERT_EQ(3, subnets->size()); // We expect 3 subnets.
// Check subnet 1. // Check subnet 1.
auto subnet = subnets->begin(); auto subnet = subnets->begin();
ASSERT_TRUE(subnet != subnets->end()); ASSERT_TRUE(subnet != subnets->end());
...@@ -485,7 +486,7 @@ TEST_F(JSONFileBackendTest, hashComments) { ...@@ -485,7 +486,7 @@ TEST_F(JSONFileBackendTest, hashComments) {
srv.reset(new ControlledDhcpv6Srv(0)) srv.reset(new ControlledDhcpv6Srv(0))
); );
// And configure it using config without // And configure it using config with comments.
EXPECT_NO_THROW(srv->init(TEST_FILE)); EXPECT_NO_THROW(srv->init(TEST_FILE));
// Now check if the configuration has been applied correctly. // Now check if the configuration has been applied correctly.
...@@ -537,7 +538,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) { ...@@ -537,7 +538,7 @@ TEST_F(JSONFileBackendTest, cppLineComments) {
srv.reset(new ControlledDhcpv6Srv(0)) srv.reset(new ControlledDhcpv6Srv(0))
); );
// And configure it using config without // And configure it using config with comments.
EXPECT_NO_THROW(srv->init(TEST_FILE)); EXPECT_NO_THROW(srv->init(TEST_FILE));
// Now check if the configuration has been applied correctly. // Now check if the configuration has been applied correctly.
...@@ -581,7 +582,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) { ...@@ -581,7 +582,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) {
"\"valid-lifetime\": 4000 }" "\"valid-lifetime\": 4000 }"
"}"; "}";
writeFile(TEST_FILE, config_c_block_comments); writeFile(TEST_FILE, config_c_block_comments);
// Now initialize the server // Now initialize the server
boost::scoped_ptr<ControlledDhcpv6Srv> srv; boost::scoped_ptr<ControlledDhcpv6Srv> srv;
...@@ -589,7 +590,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) { ...@@ -589,7 +590,7 @@ TEST_F(JSONFileBackendTest, cBlockComments) {
srv.reset(new ControlledDhcpv6Srv(0)) srv.reset(new ControlledDhcpv6Srv(0))
); );
// And configure it using config without // And configure it using config with comments.
EXPECT_NO_THROW(srv->init(TEST_FILE)); EXPECT_NO_THROW(srv->init(TEST_FILE));
// Now check if the configuration has been applied correctly. // Now check if the configuration has been applied correctly.
...@@ -641,7 +642,7 @@ TEST_F(JSONFileBackendTest, include) { ...@@ -641,7 +642,7 @@ TEST_F(JSONFileBackendTest, include) {
srv.reset(new ControlledDhcpv6Srv(0)) srv.reset(new ControlledDhcpv6Srv(0))
); );
// And configure it using config without // And configure it using config with comments.
EXPECT_NO_THROW(srv->init(TEST_FILE)); EXPECT_NO_THROW(srv->init(TEST_FILE));
// Now check if the configuration has been applied correctly. // Now check if the configuration has been applied correctly.
...@@ -687,14 +688,13 @@ TEST_F(JSONFileBackendTest, recursiveInclude) { ...@@ -687,14 +688,13 @@ TEST_F(JSONFileBackendTest, recursiveInclude) {
writeFile(TEST_FILE, config_recursive_include); writeFile(TEST_FILE, config_recursive_include);
writeFile(TEST_INCLUDE, include); writeFile(TEST_INCLUDE, include);
// Now initialize the server // Now initialize the server
boost::scoped_ptr<ControlledDhcpv6Srv> srv; boost::scoped_ptr<ControlledDhcpv6Srv> srv;
ASSERT_NO_THROW( ASSERT_NO_THROW(
srv.reset(new ControlledDhcpv6Srv(0)) srv.reset(new ControlledDhcpv6Srv(0))
); );
// And configure it using config // And configure it using config with comments.
try { try {
srv->init(TEST_FILE); srv->init(TEST_FILE);
FAIL() << "Expected Dhcp6ParseError but nothing was raised"; FAIL() << "Expected Dhcp6ParseError but nothing was raised";
...@@ -704,7 +704,6 @@ TEST_F(JSONFileBackendTest, recursiveInclude) { ...@@ -704,7 +704,6 @@ TEST_F(JSONFileBackendTest, recursiveInclude) {
} }
} }
// This test checks if configuration can be read from a JSON file.
// This test checks if configuration detects failure when trying: // This test checks if configuration detects failure when trying:
// - empty file // - empty file
// - empty filename // - empty filename
...@@ -895,7 +894,6 @@ TEST_F(JSONFileBackendTest, defaultLeaseDbBackend) { ...@@ -895,7 +894,6 @@ TEST_F(JSONFileBackendTest, defaultLeaseDbBackend) {
EXPECT_NO_THROW(static_cast<void>(LeaseMgrFactory::instance())); EXPECT_NO_THROW(static_cast<void>(LeaseMgrFactory::instance()));
} }
// This test verifies that the timer triggering configuration updates // This test verifies that the timer triggering configuration updates
// is invoked according to the configured value of the // is invoked according to the configured value of the
// config-fetch-wait-time. // config-fetch-wait-time.
...@@ -958,7 +956,7 @@ public: ...@@ -958,7 +956,7 @@ public:
/// ///
/// Destroys MySQL schema. /// Destroys MySQL schema.
virtual ~JSONFileBackendMySQLTest() { virtual ~JSONFileBackendMySQLTest() {
// If data wipe enabled, delete transient data otherwise destroy the schema // If data wipe enabled, delete transient data otherwise destroy the schema.
destroyMySQLSchema(); destroyMySQLSchema();
} }
......
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