Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenGri committed Mar 9, 2023
1 parent 2554455 commit e8e0f67
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/mock_tests/intfmgrd/add_ipv6_prefix_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ int cb(const std::string &cmd, std::string &stdout){
return 0;
}


int cb2(const std::string &cmd, std::string &stdout){
if (cmd == "/sbin/ip link set \"Ethernet64.10\" \"up\""){
return 1;
}
return 0;
}


// Test Fixture
namespace add_ipv6_prefix_ut
{
Expand Down Expand Up @@ -106,4 +115,20 @@ namespace add_ipv6_prefix_ut
}
ASSERT_EQ(ip_cmd_called, 1);
}

TEST_F(IntfMgrTest, testEden){
callback = cb2;
swss::IntfMgr intfmgr(m_config_db.get(), m_app_db.get(), m_state_db.get(), cfg_intf_tables);
intfmgr.setHostSubIntfAdminStatus("Ethernet64.10", "up", "up");
}

TEST_F(IntfMgrTest, testEden2){
callback = cb2;
swss::IntfMgr intfmgr(m_config_db.get(), m_app_db.get(), m_state_db.get(), cfg_intf_tables);
/* Set portStateTable */
std::vector<swss::FieldValueTuple> values;
values.emplace_back("state", "ok");
intfmgr.m_statePortTable.set("Ethernet64.10", values, "SET", "");
EXPECT_THROW(intfmgr.setHostSubIntfAdminStatus("Ethernet64.10", "up", "up"), std::runtime_error);
}
}

0 comments on commit e8e0f67

Please sign in to comment.