Mercurial > irccd
comparison tests/cmd-server-cmode/main.cpp @ 297:a76ccf092570
Tests: add test for server-cmode, #559
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 19 Oct 2016 13:43:12 +0200 |
parents | |
children | a6c3d73d9641 |
comparison
equal
deleted
inserted
replaced
296:c970b293d8cf | 297:a76ccf092570 |
---|---|
1 /* | |
2 * main.cpp -- test server-cmode remote command | |
3 * | |
4 * Copyright (c) 2013-2016 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 #include <cmd-server-cmode.hpp> | |
20 #include <command-tester.hpp> | |
21 #include <server-tester.hpp> | |
22 | |
23 using namespace irccd; | |
24 using namespace irccd::command; | |
25 | |
26 namespace { | |
27 | |
28 std::string channel; | |
29 std::string mode; | |
30 | |
31 } // !namespace | |
32 | |
33 class ServerChannelModeTest : public ServerTester { | |
34 public: | |
35 void cmode(std::string channel, std::string mode) | |
36 { | |
37 ::channel = channel; | |
38 ::mode = mode; | |
39 } | |
40 }; | |
41 | |
42 class ServerChannelModeCommandTest : public CommandTester { | |
43 public: | |
44 ServerChannelModeCommandTest() | |
45 : CommandTester(std::make_unique<ServerChannelModeCommand>(), | |
46 std::make_unique<ServerChannelModeTest>()) | |
47 { | |
48 m_irccdctl.client().request({ | |
49 { "command", "server-cmode" }, | |
50 { "server", "test" }, | |
51 { "channel", "#staff" }, | |
52 { "mode", "+c" } | |
53 }); | |
54 } | |
55 }; | |
56 | |
57 TEST_F(ServerChannelModeCommandTest, basic) | |
58 { | |
59 try { | |
60 poll([&] () { | |
61 return !channel.empty() && !mode.empty(); | |
62 }); | |
63 | |
64 ASSERT_EQ("#staff", channel); | |
65 ASSERT_EQ("+c", mode); | |
66 } catch (const std::exception &ex) { | |
67 FAIL() << ex.what(); | |
68 } | |
69 } | |
70 | |
71 int main(int argc, char **argv) | |
72 { | |
73 testing::InitGoogleTest(&argc, argv); | |
74 | |
75 return RUN_ALL_TESTS(); | |
76 } |