Mercurial > irccd
comparison tests/src/libirccd/command-plugin-info/main.cpp @ 651:1081e45b8628
Tests: use command_test::request helper, closes #784 @1h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 27 Mar 2018 20:12:02 +0200 |
parents | 7e2d0739f37c |
children | 3e816cebed2c |
comparison
equal
deleted
inserted
replaced
650:27896e9bcd9e | 651:1081e45b8628 |
---|---|
35 | 35 |
36 plg->set_author("Francis Beaugrand"); | 36 plg->set_author("Francis Beaugrand"); |
37 plg->set_license("GPL"); | 37 plg->set_license("GPL"); |
38 plg->set_summary("Completely useless plugin"); | 38 plg->set_summary("Completely useless plugin"); |
39 plg->set_version("0.0.0.0.0.0.0.0.1-beta5"); | 39 plg->set_version("0.0.0.0.0.0.0.0.1-beta5"); |
40 daemon_->plugins().add(std::move(plg)); | |
40 | 41 |
41 daemon_->plugins().add(std::move(plg)); | 42 const auto result = request({ |
42 ctl_->recv([&] (auto, auto msg) { | |
43 response = std::move(msg); | |
44 }); | |
45 ctl_->send({ | |
46 { "command", "plugin-info" }, | 43 { "command", "plugin-info" }, |
47 { "plugin", "test" }, | 44 { "plugin", "test" }, |
48 }); | 45 }); |
49 | 46 |
50 wait_for([&] () { | 47 BOOST_TEST(result.first["author"].get<std::string>() == "Francis Beaugrand"); |
51 return response.is_object(); | 48 BOOST_TEST(result.first["license"].get<std::string>() == "GPL"); |
52 }); | 49 BOOST_TEST(result.first["summary"].get<std::string>() == "Completely useless plugin"); |
53 | 50 BOOST_TEST(result.first["version"].get<std::string>() == "0.0.0.0.0.0.0.0.1-beta5"); |
54 BOOST_TEST(response.is_object()); | |
55 BOOST_TEST(response["author"].get<std::string>() == "Francis Beaugrand"); | |
56 BOOST_TEST(response["license"].get<std::string>() == "GPL"); | |
57 BOOST_TEST(response["summary"].get<std::string>() == "Completely useless plugin"); | |
58 BOOST_TEST(response["version"].get<std::string>() == "0.0.0.0.0.0.0.0.1-beta5"); | |
59 } | 51 } |
60 | 52 |
61 BOOST_AUTO_TEST_SUITE(errors) | 53 BOOST_AUTO_TEST_SUITE(errors) |
62 | 54 |
63 BOOST_AUTO_TEST_CASE(invalid_identifier) | 55 BOOST_AUTO_TEST_CASE(invalid_identifier) |
64 { | 56 { |
65 boost::system::error_code result; | 57 const auto result = request({ |
66 nlohmann::json message; | |
67 | |
68 ctl_->send({ | |
69 { "command", "plugin-info" } | 58 { "command", "plugin-info" } |
70 }); | 59 }); |
71 ctl_->recv([&] (auto rresult, auto rmessage) { | |
72 result = rresult; | |
73 message = rmessage; | |
74 }); | |
75 | 60 |
76 wait_for([&] { | 61 BOOST_TEST(result.second == plugin_error::invalid_identifier); |
77 return result; | 62 BOOST_TEST(result.first["error"].template get<int>() == plugin_error::invalid_identifier); |
78 }); | 63 BOOST_TEST(result.first["errorCategory"].template get<std::string>() == "plugin"); |
79 | |
80 BOOST_TEST(result == plugin_error::invalid_identifier); | |
81 BOOST_TEST(message["error"].template get<int>() == plugin_error::invalid_identifier); | |
82 BOOST_TEST(message["errorCategory"].template get<std::string>() == "plugin"); | |
83 } | 64 } |
84 | 65 |
85 BOOST_AUTO_TEST_CASE(not_found) | 66 BOOST_AUTO_TEST_CASE(not_found) |
86 { | 67 { |
87 boost::system::error_code result; | 68 const auto result = request({ |
88 nlohmann::json message; | |
89 | |
90 ctl_->send({ | |
91 { "command", "plugin-info" }, | 69 { "command", "plugin-info" }, |
92 { "plugin", "unknown" } | 70 { "plugin", "unknown" } |
93 }); | 71 }); |
94 ctl_->recv([&] (auto rresult, auto rmessage) { | |
95 result = rresult; | |
96 message = rmessage; | |
97 }); | |
98 | 72 |
99 wait_for([&] { | 73 BOOST_TEST(result.second == plugin_error::not_found); |
100 return result; | 74 BOOST_TEST(result.first["error"].template get<int>() == plugin_error::not_found); |
101 }); | 75 BOOST_TEST(result.first["errorCategory"].template get<std::string>() == "plugin"); |
102 | |
103 BOOST_TEST(result == plugin_error::not_found); | |
104 BOOST_TEST(message["error"].template get<int>() == plugin_error::not_found); | |
105 BOOST_TEST(message["errorCategory"].template get<std::string>() == "plugin"); | |
106 } | 76 } |
107 | 77 |
108 BOOST_AUTO_TEST_SUITE_END() | 78 BOOST_AUTO_TEST_SUITE_END() |
109 | 79 |
110 BOOST_AUTO_TEST_SUITE_END() | 80 BOOST_AUTO_TEST_SUITE_END() |