Commit c362eac0 authored by Marcin Siodelski's avatar Marcin Siodelski

[5107] Modified agent's unit tests to use list of answers.

parent ac671e61
...@@ -46,8 +46,16 @@ public: ...@@ -46,8 +46,16 @@ public:
/// @param expected_code code expected to be returned in the answer /// @param expected_code code expected to be returned in the answer
void checkAnswer(ConstElementPtr answer, int expected_code) { void checkAnswer(ConstElementPtr answer, int expected_code) {
int status_code; int status_code;
isc::config::parseAnswer(status_code, answer); // There may be multiple answers returned within a list.
EXPECT_EQ(expected_code, status_code); std::vector<ElementPtr> answer_list = answer->listValue();
// There must be at least one answer.
ASSERT_GE(answer_list.size(), 1);
// Check that all answers indicate success.
for (auto ans = answer_list.cbegin(); ans != answer_list.cend();
++ans) {
ASSERT_NO_THROW(isc::config::parseAnswer(status_code, *ans));
EXPECT_EQ(expected_code, status_code);
}
} }
/// @brief a convenience reference to control agent command manager /// @brief a convenience reference to control agent command manager
...@@ -57,9 +65,7 @@ public: ...@@ -57,9 +65,7 @@ public:
/// Just a basic test checking that non-existent command is handled /// Just a basic test checking that non-existent command is handled
/// properly. /// properly.
TEST_F(CtrlAgentCommandMgrTest, bogus) { TEST_F(CtrlAgentCommandMgrTest, bogus) {
ConstElementPtr answer; ConstElementPtr answer;
EXPECT_NO_THROW(answer = mgr_.handleCommand("fish-and-chips-please", EXPECT_NO_THROW(answer = mgr_.handleCommand("fish-and-chips-please",
ConstElementPtr())); ConstElementPtr()));
checkAnswer(answer, isc::config::CONTROL_RESULT_ERROR); checkAnswer(answer, isc::config::CONTROL_RESULT_ERROR);
...@@ -67,12 +73,10 @@ TEST_F(CtrlAgentCommandMgrTest, bogus) { ...@@ -67,12 +73,10 @@ TEST_F(CtrlAgentCommandMgrTest, bogus) {
/// Just a basic test checking that 'list-commands' is supported. /// Just a basic test checking that 'list-commands' is supported.
TEST_F(CtrlAgentCommandMgrTest, listCommands) { TEST_F(CtrlAgentCommandMgrTest, listCommands) {
ConstElementPtr answer; ConstElementPtr answer;
EXPECT_NO_THROW(answer = mgr_.handleCommand("list-commands", EXPECT_NO_THROW(answer = mgr_.handleCommand("list-commands",
ConstElementPtr())); ConstElementPtr()));
checkAnswer(answer, isc::config::CONTROL_RESULT_ERROR); checkAnswer(answer, isc::config::CONTROL_RESULT_SUCCESS);
}; };
......
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