Commit 5c64cab2 authored by Francis Dupont's avatar Francis Dupont Committed by Marcin Siodelski

[#1041] Added HA command processed test

parent 4915d551
......@@ -535,5 +535,34 @@ TEST_F(HAImplTest, continueHandler) {
checkAnswer(response, CONTROL_RESULT_SUCCESS, "HA state machine is not paused.");
}
// Tests status-get command processed handler.
TEST_F(HAImplTest, statusGet) {
HAImpl ha_impl;
ASSERT_NO_THROW(ha_impl.configure(createValidJsonConfiguration()));
// Starting the service is required prior to running any callouts.
NetworkStatePtr network_state(new NetworkState(NetworkState::DHCPv4));
ASSERT_NO_THROW(ha_impl.startService(io_service_, network_state,
HAServerType::DHCPv4));
std::string name = "status-get";
ConstElementPtr response =
Element::fromJSON("{ \"arguments\": { \"pid\": 1 }, \"result\": 0 }");
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
callout_handle->setArgument("name", name);
callout_handle->setArgument("response", response);
ASSERT_NO_THROW(ha_impl.commandProcessed(*callout_handle));
ConstElementPtr got;
callout_handle->getArgument("response", got);
ASSERT_TRUE(got);
std::string expected =
"{ \"arguments\": { \"ha-state\": \"waiting\", \"pid\": 1 }, \"result\": 0 }";
EXPECT_EQ(expected, got->str());
}
}
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