Mercurial > irccd
diff tests/cmd-plugin-info/main.cpp @ 570:153e84e7b09b
Tests: add error code support in cmd-plugin-* tests
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 28 Nov 2017 17:17:30 +0100 |
parents | 9b6b0d7d89c6 |
children |
line wrap: on
line diff
--- a/tests/cmd-plugin-info/main.cpp Tue Nov 28 13:57:09 2017 +0100 +++ b/tests/cmd-plugin-info/main.cpp Tue Nov 28 17:17:30 2017 +0100 @@ -58,28 +58,29 @@ BOOST_TEST(response["version"].get<std::string>() == "0.0.0.0.0.0.0.0.1-beta5"); } -BOOST_AUTO_TEST_CASE(notfound) +BOOST_AUTO_TEST_SUITE(errors) + +BOOST_AUTO_TEST_CASE(not_found) { - auto response = nlohmann::json(); + boost::system::error_code result; - ctl_->recv([&] (auto, auto msg) { - response = std::move(msg); + ctl_->send({ + { "command", "plugin-info" }, + { "plugin", "unknown" } }); - ctl_->send({ - { "command", "plugin-info" }, - { "plugin", "test" }, + ctl_->recv([&] (auto code, auto) { + result = code; }); - wait_for([&] () { - return response.is_object(); + wait_for([&] { + return result; }); - BOOST_TEST(response.is_object()); - - // TODO: error code here. - BOOST_TEST(response["error"].get<std::string>() == "plugin test not found"); + BOOST_ASSERT(result == plugin_error::not_found); } BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + } // !irccd