comparison tests/src/irccdctl/cli-server-kick/main.cpp @ 743:473ce856c161

Tests: add irccdctl server-* tests #785
author David Demelier <markand@malikania.fr>
date Thu, 26 Jul 2018 12:29:00 +0200
parents
children 903415e8ee2e
comparison
equal deleted inserted replaced
742:d3660cbf2f3c 743:473ce856c161
1 /*
2 * main.cpp -- test irccdctl server-kick
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 "irccdctl server-kick"
20 #include <boost/test/unit_test.hpp>
21
22 #include <irccd/test/server_cli_test.hpp>
23
24 namespace irccd {
25
26 namespace {
27
28 BOOST_FIXTURE_TEST_SUITE(server_kick_suite, server_cli_test)
29
30 BOOST_AUTO_TEST_CASE(basic)
31 {
32 start();
33
34 const auto [code, out, err] = exec({ "server-kick", "test", "francis", "#staff" });
35
36 BOOST_TEST(!code);
37 BOOST_TEST(out.size() == 0U);
38 BOOST_TEST(err.size() == 0U);
39
40 const auto cmd = server_->find("kick");
41
42 BOOST_TEST(cmd.size() == 1U);
43 BOOST_TEST(std::any_cast<std::string>(cmd[0][0]) == "francis");
44 BOOST_TEST(std::any_cast<std::string>(cmd[0][1]) == "#staff");
45 BOOST_TEST(std::any_cast<std::string>(cmd[0][2]) == "");
46 }
47
48 BOOST_AUTO_TEST_CASE(with_reason)
49 {
50 start();
51
52 const auto [code, out, err] = exec({ "server-kick", "test", "francis", "#staff", "shhh" });
53
54 BOOST_TEST(!code);
55 BOOST_TEST(out.size() == 0U);
56 BOOST_TEST(err.size() == 0U);
57
58 const auto cmd = server_->find("kick");
59
60 BOOST_TEST(cmd.size() == 1U);
61 BOOST_TEST(std::any_cast<std::string>(cmd[0][0]) == "francis");
62 BOOST_TEST(std::any_cast<std::string>(cmd[0][1]) == "#staff");
63 BOOST_TEST(std::any_cast<std::string>(cmd[0][2]) == "shhh");
64 }
65
66 BOOST_AUTO_TEST_SUITE_END()
67
68 } // !namespace
69
70 } // !irccd