comparison tests/src/irccdctl/cli-server-mode/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-mode
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-mode"
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_mode_suite, server_cli_test)
29
30 BOOST_AUTO_TEST_CASE(user)
31 {
32 start();
33
34 const auto [code, out, err] = exec({ "server-mode", "test", "irccd", "+i" });
35
36 BOOST_TEST(!code);
37 BOOST_TEST(out.size() == 0U);
38 BOOST_TEST(err.size() == 0U);
39
40 const auto cmd = server_->find("mode");
41
42 BOOST_TEST(cmd.size() == 1U);
43 BOOST_TEST(std::any_cast<std::string>(cmd[0][0]) == "irccd");
44 BOOST_TEST(std::any_cast<std::string>(cmd[0][1]) == "+i");
45 BOOST_TEST(std::any_cast<std::string>(cmd[0][2]) == "");
46 BOOST_TEST(std::any_cast<std::string>(cmd[0][3]) == "");
47 BOOST_TEST(std::any_cast<std::string>(cmd[0][4]) == "");
48 }
49
50 BOOST_AUTO_TEST_CASE(channel)
51 {
52 start();
53
54 const auto [code, out, err] = exec({ "server-mode", "test", "#staff", "+b", "francis" });
55
56 BOOST_TEST(!code);
57 BOOST_TEST(out.size() == 0U);
58 BOOST_TEST(err.size() == 0U);
59
60 const auto cmd = server_->find("mode");
61
62 BOOST_TEST(cmd.size() == 1U);
63 BOOST_TEST(std::any_cast<std::string>(cmd[0][0]) == "#staff");
64 BOOST_TEST(std::any_cast<std::string>(cmd[0][1]) == "+b");
65 BOOST_TEST(std::any_cast<std::string>(cmd[0][2]) == "francis");
66 BOOST_TEST(std::any_cast<std::string>(cmd[0][3]) == "");
67 BOOST_TEST(std::any_cast<std::string>(cmd[0][4]) == "");
68 }
69
70 BOOST_AUTO_TEST_SUITE_END()
71
72 } // !namespace
73
74 } // !irccd