Mercurial > irccd
comparison tests/src/libirccd-daemon/command-plugin-info/main.cpp @ 809:8460b4a34191
misc: reorganize namespaces, closes #952 @4h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 16 Nov 2018 12:25:00 +0100 |
parents | tests/src/libirccd/command-plugin-info/main.cpp@8c44bbcbbab9 |
children | 06cc2f95f479 |
comparison
equal
deleted
inserted
replaced
808:80bccab4a093 | 809:8460b4a34191 |
---|---|
1 /* | |
2 * main.cpp -- test plugin-info remote command | |
3 * | |
4 * Copyright (c) 2013-2018 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/test/command_fixture.hpp> | |
23 | |
24 using irccd::test::command_fixture; | |
25 using irccd::test::mock_plugin; | |
26 | |
27 using irccd::daemon::plugin_error; | |
28 | |
29 namespace irccd { | |
30 | |
31 namespace { | |
32 | |
33 BOOST_FIXTURE_TEST_SUITE(plugin_info_test_suite, command_fixture) | |
34 | |
35 BOOST_AUTO_TEST_CASE(basic) | |
36 { | |
37 const auto [json, code] = request({ | |
38 { "command", "plugin-info" }, | |
39 { "plugin", "test" }, | |
40 }); | |
41 | |
42 BOOST_TEST(!code); | |
43 BOOST_TEST(json["author"].get<std::string>() == "David Demelier <markand@malikania.fr>"); | |
44 BOOST_TEST(json["license"].get<std::string>() == "ISC"); | |
45 BOOST_TEST(json["summary"].get<std::string>() == "mock plugin"); | |
46 BOOST_TEST(json["version"].get<std::string>() == "1.0"); | |
47 } | |
48 | |
49 BOOST_AUTO_TEST_SUITE(errors) | |
50 | |
51 BOOST_AUTO_TEST_CASE(invalid_identifier) | |
52 { | |
53 const auto [json, code] = request({ | |
54 { "command", "plugin-info" } | |
55 }); | |
56 | |
57 BOOST_TEST(code == plugin_error::invalid_identifier); | |
58 BOOST_TEST(json["error"].get<int>() == plugin_error::invalid_identifier); | |
59 BOOST_TEST(json["errorCategory"].get<std::string>() == "plugin"); | |
60 } | |
61 | |
62 BOOST_AUTO_TEST_CASE(not_found) | |
63 { | |
64 const auto [json, code] = request({ | |
65 { "command", "plugin-info" }, | |
66 { "plugin", "unknown" } | |
67 }); | |
68 | |
69 BOOST_TEST(code == plugin_error::not_found); | |
70 BOOST_TEST(json["error"].get<int>() == plugin_error::not_found); | |
71 BOOST_TEST(json["errorCategory"].get<std::string>() == "plugin"); | |
72 } | |
73 | |
74 BOOST_AUTO_TEST_SUITE_END() | |
75 | |
76 BOOST_AUTO_TEST_SUITE_END() | |
77 | |
78 } // !namespace | |
79 | |
80 } // !irccd |