Commit c362eac0 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

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

parent ac671e61
......@@ -46,8 +46,16 @@ public:
/// @param expected_code code expected to be returned in the answer
void checkAnswer(ConstElementPtr answer, int expected_code) {
int status_code;
isc::config::parseAnswer(status_code, answer);
EXPECT_EQ(expected_code, status_code);
// There may be multiple answers returned within a list.
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
......@@ -57,9 +65,7 @@ public:
/// Just a basic test checking that non-existent command is handled
/// properly.
TEST_F(CtrlAgentCommandMgrTest, bogus) {
ConstElementPtr answer;
EXPECT_NO_THROW(answer = mgr_.handleCommand("fish-and-chips-please",
checkAnswer(answer, isc::config::CONTROL_RESULT_ERROR);
......@@ -67,12 +73,10 @@ TEST_F(CtrlAgentCommandMgrTest, bogus) {
/// Just a basic test checking that 'list-commands' is supported.
TEST_F(CtrlAgentCommandMgrTest, listCommands) {
ConstElementPtr answer;
EXPECT_NO_THROW(answer = mgr_.handleCommand("list-commands",
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