comparison tests/src/libirccd/command-plugin-reload/main.cpp @ 641:7e2d0739f37c

Irccd: import json_util from code Change how parsing values from JSON is done, the json_util functions do not throw but return a boost::optional instead. Then, create some convenient local wrappers in server_util.cpp to throw on missing values. While here, add as much as possible const qualifier on variables that will not be modified.
author David Demelier <markand@malikania.fr>
date Tue, 20 Mar 2018 20:01:02 +0100
parents 152d20dc0e74
children 1081e45b8628
comparison
equal deleted inserted replaced
640:e2ad41b02ebf 641:7e2d0739f37c
83 BOOST_TEST(plugin_->reloaded); 83 BOOST_TEST(plugin_->reloaded);
84 } 84 }
85 85
86 BOOST_AUTO_TEST_SUITE(errors) 86 BOOST_AUTO_TEST_SUITE(errors)
87 87
88 BOOST_AUTO_TEST_CASE(invalid_identifier)
89 {
90 boost::system::error_code result;
91 nlohmann::json message;
92
93 ctl_->send({
94 { "command", "plugin-reload" }
95 });
96 ctl_->recv([&] (auto rresult, auto rmessage) {
97 result = rresult;
98 message = rmessage;
99 });
100
101 wait_for([&] {
102 return result;
103 });
104
105 BOOST_TEST(result == plugin_error::invalid_identifier);
106 BOOST_TEST(message["error"].template get<int>() == plugin_error::invalid_identifier);
107 BOOST_TEST(message["errorCategory"].template get<std::string>() == "plugin");
108 }
109
88 BOOST_AUTO_TEST_CASE(not_found) 110 BOOST_AUTO_TEST_CASE(not_found)
89 { 111 {
90 boost::system::error_code result; 112 boost::system::error_code result;
91 nlohmann::json message; 113 nlohmann::json message;
92 114