annotate tests/src/libirccd/command-rule-remove/main.cpp @ 624:f69b1faf812f

Irccd: split commands, closes #759 @2h
author David Demelier <markand@malikania.fr>
date Fri, 22 Dec 2017 21:31:31 +0100
parents 9fbd1700435b
children c6000e13ab02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 /*
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 * main.cpp -- test rule-remove remote command
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 *
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr>
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 *
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 * Permission to use, copy, modify, and/or distribute this software for any
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 * copyright notice and this permission notice appear in all copies.
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 *
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 */
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
19 #define BOOST_TEST_MODULE "rule-remove"
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
20 #include <boost/test/unit_test.hpp>
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
21
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
22 #include <irccd/json_util.hpp>
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
23
624
f69b1faf812f Irccd: split commands, closes #759 @2h
David Demelier <markand@malikania.fr>
parents: 611
diff changeset
24 #include <irccd/daemon/rule_remove_command.hpp>
f69b1faf812f Irccd: split commands, closes #759 @2h
David Demelier <markand@malikania.fr>
parents: 611
diff changeset
25 #include <irccd/daemon/rule_list_command.hpp>
596
35832b7f4f9d Irccd: move files to daemon folder, closes #731
David Demelier <markand@malikania.fr>
parents: 595
diff changeset
26 #include <irccd/daemon/rule_service.hpp>
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
27
604
9d4da384f5d6 Tests: move libirccd-test to test/ folder, closes #750
David Demelier <markand@malikania.fr>
parents: 596
diff changeset
28 #include <irccd/test/command_test.hpp>
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
29
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
30 namespace irccd {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
31
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
32 namespace {
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
33
595
029667d16d12 Tests: add multiple commands in command_test
David Demelier <markand@malikania.fr>
parents: 581
diff changeset
34 class rule_remove_test : public command_test<rule_remove_command, rule_list_command> {
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 public:
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
36 rule_remove_test()
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 {
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
38 daemon_->rules().add(rule(
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 { "s1", "s2" },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 { "c1", "c2" },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 { "o1", "o2" },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 { "p1", "p2" },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 { "onMessage", "onCommand" },
488
7e273b7f4f92 Irccd: new coding style, closes #576
David Demelier <markand@malikania.fr>
parents: 450
diff changeset
44 rule::action_type::drop
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 ));
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
46 daemon_->rules().add(rule(
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
47 { "s1", },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 { "c1", },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 { "o1", },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 { "p1", },
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 { "onMessage", },
488
7e273b7f4f92 Irccd: new coding style, closes #576
David Demelier <markand@malikania.fr>
parents: 450
diff changeset
52 rule::action_type::accept
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 ));
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 }
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
55 };
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
56
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
57 } // !namespace
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
58
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
59 BOOST_FIXTURE_TEST_SUITE(rule_remove_test_suite, rule_remove_test)
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
60
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
61 BOOST_AUTO_TEST_CASE(basic)
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 {
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
63 nlohmann::json result;
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
64
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
65 ctl_->send({
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
66 { "command", "rule-remove" },
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
67 { "index", 1 }
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
68 });
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
69 ctl_->recv([&] (auto, auto msg) {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
70 result = msg;
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
71 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
72
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
73 wait_for([&] () {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
74 return result.is_object();
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
75 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
76
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
77 BOOST_TEST(result.is_object());
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
78
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
79 result = nullptr;
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
80 ctl_->send({{ "command", "rule-list" }});
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
81 ctl_->recv([&] (auto, auto msg) {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
82 result = msg;
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
83 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
84
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
85 wait_for([&] () {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
86 return result.is_object();
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
87 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
88
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
89 BOOST_TEST(result["list"].is_array());
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
90 BOOST_TEST(result["list"].size() == 1U);
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
91
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
92 auto servers = result["list"][0]["servers"];
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
93 auto channels = result["list"][0]["channels"];
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
94 auto plugins = result["list"][0]["plugins"];
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
95 auto events = result["list"][0]["events"];
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
96
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
97 BOOST_TEST(json_util::contains(servers, "s1"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
98 BOOST_TEST(json_util::contains(servers, "s2"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
99 BOOST_TEST(json_util::contains(channels, "c1"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
100 BOOST_TEST(json_util::contains(channels, "c2"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
101 BOOST_TEST(json_util::contains(plugins, "p1"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
102 BOOST_TEST(json_util::contains(plugins, "p2"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
103 BOOST_TEST(json_util::contains(events, "onMessage"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
104 BOOST_TEST(json_util::contains(events, "onCommand"));
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
105 BOOST_TEST(result["list"][0]["action"].get<std::string>() == "drop");
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
106 }
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
107
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
108 BOOST_AUTO_TEST_CASE(empty)
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
109 {
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
110 nlohmann::json result;
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
111
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
112 daemon_->rules().remove(0);
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
113 daemon_->rules().remove(0);
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
114
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
115 ctl_->send({
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
116 { "command", "rule-remove" },
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
117 { "index", 1 }
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
118 });
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
119 ctl_->recv([&] (auto, auto msg) {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
120 result = msg;
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
121 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
122
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
123 wait_for([&] () {
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
124 return result.is_object();
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
125 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
126
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
127 BOOST_TEST(result.is_object());
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
128 }
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
129
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
130 BOOST_AUTO_TEST_SUITE(errors)
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
131
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
132 BOOST_AUTO_TEST_CASE(invalid_index_1)
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
133 {
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
134 boost::system::error_code result;
609
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
135 nlohmann::json message;
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
136
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
137 ctl_->send({
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
138 { "command", "rule-remove" },
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
139 { "index", -100 }
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
140 });
609
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
141 ctl_->recv([&] (auto rresult, auto rmessage) {
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
142 result = rresult;
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
143 message = rmessage;
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
144 });
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
145
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
146 wait_for([&] {
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
147 return result;
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
148 });
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
149
610
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
150 BOOST_TEST(result == rule_error::invalid_index);
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
151 BOOST_TEST(message["error"].template get<int>() == rule_error::invalid_index);
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
152 BOOST_TEST(message["errorCategory"].template get<std::string>() == "rule");
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
153 }
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
154
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
155 BOOST_AUTO_TEST_CASE(invalid_index_2)
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
156 {
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
157 boost::system::error_code result;
609
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
158 nlohmann::json message;
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
159
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
160 ctl_->send({
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
161 { "command", "rule-remove" },
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
162 { "index", 100 }
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
163 });
609
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
164 ctl_->recv([&] (auto rresult, auto rmessage) {
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
165 result = rresult;
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
166 message = rmessage;
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
167 });
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
168
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
169 wait_for([&] {
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
170 return result;
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
171 });
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
172
610
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
173 BOOST_TEST(result == rule_error::invalid_index);
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
174 BOOST_TEST(message["error"].template get<int>() == rule_error::invalid_index);
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
175 BOOST_TEST(message["errorCategory"].template get<std::string>() == "rule");
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
176 }
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
177
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
178 BOOST_AUTO_TEST_CASE(invalid_index_3)
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
179 {
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
180 boost::system::error_code result;
609
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
181 nlohmann::json message;
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
182
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
183 ctl_->send({
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
184 { "command", "rule-remove" },
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
185 { "index", "notaint" }
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
186 });
609
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
187 ctl_->recv([&] (auto rresult, auto rmessage) {
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
188 result = rresult;
168c0e191eea Irccd: add more error properties, closes #754
David Demelier <markand@malikania.fr>
parents: 604
diff changeset
189 message = rmessage;
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
190 });
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
191
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
192 wait_for([&] {
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
193 return result;
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
194 });
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
195
610
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
196 BOOST_TEST(result == rule_error::invalid_index);
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
197 BOOST_TEST(message["error"].template get<int>() == rule_error::invalid_index);
22b3cd6f991f Tests: sed BOOST_ASSERT/BOOST_TEST
David Demelier <markand@malikania.fr>
parents: 609
diff changeset
198 BOOST_TEST(message["errorCategory"].template get<std::string>() == "rule");
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
199 }
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
200
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
201 BOOST_AUTO_TEST_SUITE_END()
450
c8c68d4bf555 Irccdctl: implement rule-remove
David Demelier <markand@malikania.fr>
parents:
diff changeset
202
573
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
203 BOOST_AUTO_TEST_SUITE_END()
067240931226 Tests: forgot test-cmd-rule-remove in previous commit
David Demelier <markand@malikania.fr>
parents: 557
diff changeset
204
557
c729f06c6f27 Tests: convert cmd-rule-*, #593
David Demelier <markand@malikania.fr>
parents: 488
diff changeset
205 } // !irccd