Mercurial > irccd
comparison tests/src/plugins/joke/main.cpp @ 636:152d20dc0e74
Irccd: rename plugin::on_ to plugin::handle_, closes #769 @10m
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 15 Mar 2018 12:56:26 +0100 |
parents | 27587ff92a64 |
children | 3e816cebed2c |
comparison
equal
deleted
inserted
replaced
635:b452f5ce799c | 636:152d20dc0e74 |
---|---|
38 // Add file if not there. | 38 // Add file if not there. |
39 if (config.count("file") == 0) | 39 if (config.count("file") == 0) |
40 config.emplace("file", CMAKE_CURRENT_SOURCE_DIR "/jokes.json"); | 40 config.emplace("file", CMAKE_CURRENT_SOURCE_DIR "/jokes.json"); |
41 | 41 |
42 plugin_->set_config(config); | 42 plugin_->set_config(config); |
43 plugin_->on_load(irccd_); | 43 plugin_->handle_load(irccd_); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 BOOST_FIXTURE_TEST_SUITE(joke_test_suite, joke_test) | 47 BOOST_FIXTURE_TEST_SUITE(joke_test_suite, joke_test) |
48 | 48 |
64 }; | 64 }; |
65 | 65 |
66 load(); | 66 load(); |
67 | 67 |
68 auto call = [&] () { | 68 auto call = [&] () { |
69 plugin_->on_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); | 69 plugin_->handle_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); |
70 | 70 |
71 auto cmd = server_->cqueue().back(); | 71 auto cmd = server_->cqueue().back(); |
72 | 72 |
73 // "bbbb" is two lines. | 73 // "bbbb" is two lines. |
74 if (cmd["message"] == "bbbb") { | 74 if (cmd["message"] == "bbbb") { |
103 std::unordered_map<std::string, int> said{ | 103 std::unordered_map<std::string, int> said{ |
104 { "a", 0 } | 104 { "a", 0 } |
105 }; | 105 }; |
106 | 106 |
107 auto call = [&] () { | 107 auto call = [&] () { |
108 plugin_->on_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); | 108 plugin_->handle_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); |
109 | 109 |
110 auto cmd = server_->cqueue().back(); | 110 auto cmd = server_->cqueue().back(); |
111 | 111 |
112 BOOST_TEST(cmd["command"].template get<std::string>() == "message"); | 112 BOOST_TEST(cmd["command"].template get<std::string>() == "message"); |
113 BOOST_TEST(cmd["target"].template get<std::string>() == "#joke"); | 113 BOOST_TEST(cmd["target"].template get<std::string>() == "#joke"); |
135 std::unordered_map<std::string, int> said{ | 135 std::unordered_map<std::string, int> said{ |
136 { "a", 0 } | 136 { "a", 0 } |
137 }; | 137 }; |
138 | 138 |
139 auto call = [&] () { | 139 auto call = [&] () { |
140 plugin_->on_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); | 140 plugin_->handle_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); |
141 | 141 |
142 auto cmd = server_->cqueue().back(); | 142 auto cmd = server_->cqueue().back(); |
143 | 143 |
144 BOOST_TEST(cmd["command"].template get<std::string>() == "message"); | 144 BOOST_TEST(cmd["command"].template get<std::string>() == "message"); |
145 BOOST_TEST(cmd["target"].template get<std::string>() == "#joke"); | 145 BOOST_TEST(cmd["target"].template get<std::string>() == "#joke"); |
161 | 161 |
162 BOOST_AUTO_TEST_CASE(not_found) | 162 BOOST_AUTO_TEST_CASE(not_found) |
163 { | 163 { |
164 load({{"file", "doesnotexist.json"}}); | 164 load({{"file", "doesnotexist.json"}}); |
165 | 165 |
166 plugin_->on_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); | 166 plugin_->handle_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); |
167 | 167 |
168 auto cmd = server_->cqueue().back(); | 168 auto cmd = server_->cqueue().back(); |
169 | 169 |
170 BOOST_TEST(cmd["command"].get<std::string>() == "message"); | 170 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
171 BOOST_TEST(cmd["target"].get<std::string>() == "#joke"); | 171 BOOST_TEST(cmd["target"].get<std::string>() == "#joke"); |
174 | 174 |
175 BOOST_AUTO_TEST_CASE(not_array) | 175 BOOST_AUTO_TEST_CASE(not_array) |
176 { | 176 { |
177 load({{"file", CMAKE_CURRENT_SOURCE_DIR "/jokes-not-array.json"}}); | 177 load({{"file", CMAKE_CURRENT_SOURCE_DIR "/jokes-not-array.json"}}); |
178 | 178 |
179 plugin_->on_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); | 179 plugin_->handle_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); |
180 | 180 |
181 auto cmd = server_->cqueue().back(); | 181 auto cmd = server_->cqueue().back(); |
182 | 182 |
183 BOOST_TEST(cmd["command"].get<std::string>() == "message"); | 183 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
184 BOOST_TEST(cmd["target"].get<std::string>() == "#joke"); | 184 BOOST_TEST(cmd["target"].get<std::string>() == "#joke"); |
187 | 187 |
188 BOOST_AUTO_TEST_CASE(empty) | 188 BOOST_AUTO_TEST_CASE(empty) |
189 { | 189 { |
190 load({{"file", CMAKE_CURRENT_SOURCE_DIR "/jokes-empty.json"}}); | 190 load({{"file", CMAKE_CURRENT_SOURCE_DIR "/jokes-empty.json"}}); |
191 | 191 |
192 plugin_->on_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); | 192 plugin_->handle_command(irccd_, {server_, "jean!jean@localhost", "#joke", ""}); |
193 | 193 |
194 auto cmd = server_->cqueue().back(); | 194 auto cmd = server_->cqueue().back(); |
195 | 195 |
196 BOOST_TEST(cmd["command"].get<std::string>() == "message"); | 196 BOOST_TEST(cmd["command"].get<std::string>() == "message"); |
197 BOOST_TEST(cmd["target"].get<std::string>() == "#joke"); | 197 BOOST_TEST(cmd["target"].get<std::string>() == "#joke"); |