Mercurial > irccd
diff tests/src/plugin-unload-command/main.cpp @ 609:168c0e191eea
Irccd: add more error properties, closes #754
Add two new properties in error messages:
- errorMessage: the string message as-is,
- errorCategory: the error category (e.g. server, rule).
Adapt tests to test against the category.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 14 Dec 2017 21:45:32 +0100 |
parents | 9d4da384f5d6 |
children | 22b3cd6f991f |
line wrap: on
line diff
--- a/tests/src/plugin-unload-command/main.cpp Mon Dec 11 15:00:36 2017 +0100 +++ b/tests/src/plugin-unload-command/main.cpp Thu Dec 14 21:45:32 2017 +0100 @@ -88,13 +88,15 @@ BOOST_AUTO_TEST_CASE(not_found) { boost::system::error_code result; + nlohmann::json message; ctl_->send({ { "command", "plugin-unload" }, { "plugin", "unknown" } }); - ctl_->recv([&] (auto code, auto) { - result = code; + ctl_->recv([&] (auto rresult, auto rmessage) { + result = rresult; + message = rmessage; }); wait_for([&] { @@ -102,18 +104,22 @@ }); BOOST_ASSERT(result == plugin_error::not_found); + BOOST_ASSERT(message["error"].template get<int>() == plugin_error::not_found); + BOOST_ASSERT(message["errorCategory"].template get<std::string>() == "plugin"); } BOOST_AUTO_TEST_CASE(exec_error) { boost::system::error_code result; + nlohmann::json message; ctl_->send({ { "command", "plugin-unload" }, { "plugin", "broken" } }); - ctl_->recv([&] (auto code, auto) { - result = code; + ctl_->recv([&] (auto rresult, auto rmessage) { + result = rresult; + message = rmessage; }); wait_for([&] { @@ -121,6 +127,8 @@ }); BOOST_ASSERT(result == plugin_error::exec_error); + BOOST_ASSERT(message["error"].template get<int>() == plugin_error::exec_error); + BOOST_ASSERT(message["errorCategory"].template get<std::string>() == "plugin"); BOOST_ASSERT(!daemon_->plugins().has("broken")); }