Mercurial > irccd
comparison tests/src/plugins/plugin/main.cpp @ 847:a23b7b574ed2
irccd: rename [format] section to [templates], closes #1671
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 10 Jul 2019 20:10:00 +0200 |
parents | 1399755352e7 |
children | 5e25439fe98d |
comparison
equal
deleted
inserted
replaced
846:dcef68d82fd3 | 847:a23b7b574ed2 |
---|---|
74 test_fixture() | 74 test_fixture() |
75 : js_plugin_fixture(PLUGIN_PATH) | 75 : js_plugin_fixture(PLUGIN_PATH) |
76 { | 76 { |
77 bot_.get_plugins().add(std::make_shared<fake_plugin>("fake")); | 77 bot_.get_plugins().add(std::make_shared<fake_plugin>("fake")); |
78 | 78 |
79 plugin_->set_formats({ | 79 plugin_->set_templates({ |
80 { "usage", "usage=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}" }, | 80 { "usage", "usage=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}" }, |
81 { "info", "info=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{author}:#{license}:#{name}:#{summary}:#{version}" }, | 81 { "info", "info=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{author}:#{license}:#{name}:#{summary}:#{version}" }, |
82 { "not-found", "not-found=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{name}" }, | 82 { "not-found", "not-found=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{name}" }, |
83 { "too-long", "too-long=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}" } | 83 { "too-long", "too-long=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}" } |
84 }); | 84 }); |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 BOOST_FIXTURE_TEST_SUITE(test_fixture_suite, test_fixture) | 89 BOOST_FIXTURE_TEST_SUITE(test_fixture_suite, test_fixture) |
90 | 90 |
91 BOOST_AUTO_TEST_CASE(format_usage) | 91 BOOST_AUTO_TEST_CASE(template_usage) |
92 { | 92 { |
93 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "" }); | 93 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "" }); |
94 | 94 |
95 auto cmd = server_->find("message").front(); | 95 auto cmd = server_->find("message").front(); |
96 | 96 |
108 | 108 |
109 BOOST_TEST(std::any_cast<std::string>(cmd[0]) == "#staff"); | 109 BOOST_TEST(std::any_cast<std::string>(cmd[0]) == "#staff"); |
110 BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "usage=plugin:!plugin:test:#staff:jean!jean@localhost:jean"); | 110 BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "usage=plugin:!plugin:test:#staff:jean!jean@localhost:jean"); |
111 } | 111 } |
112 | 112 |
113 BOOST_AUTO_TEST_CASE(format_info) | 113 BOOST_AUTO_TEST_CASE(template_info) |
114 { | 114 { |
115 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "info fake" }); | 115 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "info fake" }); |
116 | 116 |
117 const auto cmd = server_->find("message").front(); | 117 const auto cmd = server_->find("message").front(); |
118 | 118 |
119 BOOST_TEST(std::any_cast<std::string>(cmd[0]) == "#staff"); | 119 BOOST_TEST(std::any_cast<std::string>(cmd[0]) == "#staff"); |
120 BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "info=plugin:!plugin:test:#staff:jean!jean@localhost:jean:jean:BEER:fake:Fake White Beer 2000:0.0.0.0.0.1"); | 120 BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "info=plugin:!plugin:test:#staff:jean!jean@localhost:jean:jean:BEER:fake:Fake White Beer 2000:0.0.0.0.0.1"); |
121 } | 121 } |
122 | 122 |
123 BOOST_AUTO_TEST_CASE(format_not_found) | 123 BOOST_AUTO_TEST_CASE(template_not_found) |
124 { | 124 { |
125 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "info doesnotexistsihope" }); | 125 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "info doesnotexistsihope" }); |
126 | 126 |
127 const auto cmd = server_->find("message").front(); | 127 const auto cmd = server_->find("message").front(); |
128 | 128 |
129 BOOST_TEST(std::any_cast<std::string>(cmd[0]) == "#staff"); | 129 BOOST_TEST(std::any_cast<std::string>(cmd[0]) == "#staff"); |
130 BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "not-found=plugin:!plugin:test:#staff:jean!jean@localhost:jean:doesnotexistsihope"); | 130 BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "not-found=plugin:!plugin:test:#staff:jean!jean@localhost:jean:doesnotexistsihope"); |
131 } | 131 } |
132 | 132 |
133 BOOST_AUTO_TEST_CASE(format_too_long) | 133 BOOST_AUTO_TEST_CASE(template_too_long) |
134 { | 134 { |
135 for (int i = 0; i < 100; ++i) | 135 for (int i = 0; i < 100; ++i) |
136 bot_.get_plugins().add(std::make_shared<fake_plugin>(str(format("plugin-n-%1%") % i))); | 136 bot_.get_plugins().add(std::make_shared<fake_plugin>(str(format("plugin-n-%1%") % i))); |
137 | 137 |
138 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "list" }); | 138 plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "list" }); |