Mercurial > irccd
comparison tests/src/plugin-info-command/main.cpp @ 581:a51b5dd5b761
Tests: put everything in src/
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 04 Dec 2017 14:12:13 +0100 |
parents | tests/plugin-info-command/main.cpp@84ea13c850f4 |
children | 35832b7f4f9d |
comparison
equal
deleted
inserted
replaced
580:2e16c3623531 | 581:a51b5dd5b761 |
---|---|
1 /* | |
2 * main.cpp -- test plugin-info remote command | |
3 * | |
4 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #define BOOST_TEST_MODULE "plugin-info" | |
20 #include <boost/test/unit_test.hpp> | |
21 | |
22 #include <irccd/command.hpp> | |
23 #include <irccd/plugin_service.hpp> | |
24 | |
25 #include <command_test.hpp> | |
26 | |
27 namespace irccd { | |
28 | |
29 BOOST_FIXTURE_TEST_SUITE(plugin_info_test_suite, command_test<plugin_info_command>) | |
30 | |
31 BOOST_AUTO_TEST_CASE(basic) | |
32 { | |
33 auto plg = std::make_unique<plugin>("test", ""); | |
34 auto response = nlohmann::json(); | |
35 | |
36 plg->set_author("Francis Beaugrand"); | |
37 plg->set_license("GPL"); | |
38 plg->set_summary("Completely useless plugin"); | |
39 plg->set_version("0.0.0.0.0.0.0.0.1-beta5"); | |
40 | |
41 daemon_->plugins().add(std::move(plg)); | |
42 ctl_->recv([&] (auto, auto msg) { | |
43 response = std::move(msg); | |
44 }); | |
45 ctl_->send({ | |
46 { "command", "plugin-info" }, | |
47 { "plugin", "test" }, | |
48 }); | |
49 | |
50 wait_for([&] () { | |
51 return response.is_object(); | |
52 }); | |
53 | |
54 BOOST_TEST(response.is_object()); | |
55 BOOST_TEST(response["author"].get<std::string>() == "Francis Beaugrand"); | |
56 BOOST_TEST(response["license"].get<std::string>() == "GPL"); | |
57 BOOST_TEST(response["summary"].get<std::string>() == "Completely useless plugin"); | |
58 BOOST_TEST(response["version"].get<std::string>() == "0.0.0.0.0.0.0.0.1-beta5"); | |
59 } | |
60 | |
61 BOOST_AUTO_TEST_SUITE(errors) | |
62 | |
63 BOOST_AUTO_TEST_CASE(not_found) | |
64 { | |
65 boost::system::error_code result; | |
66 | |
67 ctl_->send({ | |
68 { "command", "plugin-info" }, | |
69 { "plugin", "unknown" } | |
70 }); | |
71 ctl_->recv([&] (auto code, auto) { | |
72 result = code; | |
73 }); | |
74 | |
75 wait_for([&] { | |
76 return result; | |
77 }); | |
78 | |
79 BOOST_ASSERT(result == plugin_error::not_found); | |
80 } | |
81 | |
82 BOOST_AUTO_TEST_SUITE_END() | |
83 | |
84 BOOST_AUTO_TEST_SUITE_END() | |
85 | |
86 } // !irccd |