From 577984faf2befaa7f11a1e4a115dc8d80805fec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 18 Mar 2018 02:31:18 +0100 Subject: Allow the execution of multiple commands after the IRC connection fix #3275 --- tests/database.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/end_to_end/__main__.py | 11 ++++++----- 2 files changed, 49 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/database.cpp b/tests/database.cpp index 7ab6da8..c9b8dc7 100644 --- a/tests/database.cpp +++ b/tests/database.cpp @@ -117,6 +117,49 @@ TEST_CASE("Database") } } + SECTION("Server options") + { + const std::string owner{"toto@example.com"}; + const std::string owner2{"toto2@example.com"}; + const std::string server{"irc.example.com"}; + + auto soptions = Database::get_irc_server_options(owner, server); + auto soptions2 = Database::get_irc_server_options(owner2, server); + + auto after_connection_commands = Database::get_after_connection_commands(soptions); + CHECK(after_connection_commands.empty()); + + soptions.save(Database::db); + soptions2.save(Database::db); + auto com = Database::after_connection_commands.row(); + com.col() = "first"; + after_connection_commands.push_back(com); + com.col() = "second"; + after_connection_commands.push_back(com); + Database::set_after_connection_commands(soptions, after_connection_commands); + + after_connection_commands.clear(); + com.col() = "first"; + after_connection_commands.push_back(com); + com.col() = "second"; + after_connection_commands.push_back(com); + Database::set_after_connection_commands(soptions2, after_connection_commands); + + after_connection_commands = Database::get_after_connection_commands(soptions); + CHECK(after_connection_commands.size() == 2); + after_connection_commands = Database::get_after_connection_commands(soptions2); + CHECK(after_connection_commands.size() == 2); + + after_connection_commands.clear(); + after_connection_commands.push_back(com); + Database::set_after_connection_commands(soptions, after_connection_commands); + + after_connection_commands = Database::get_after_connection_commands(soptions); + CHECK(after_connection_commands.size() == 1); + after_connection_commands = Database::get_after_connection_commands(soptions2); + CHECK(after_connection_commands.size() == 2); + } + Database::close(); } #endif diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 99d1dd1..f3f4594 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2701,7 +2701,7 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='verify_cert']/dataform:value[text()='true']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='fingerprint']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-private'][@var='pass']", - "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='after_connect_command']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-multi'][@var='after_connect_commands']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='username']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']", @@ -2718,7 +2718,7 @@ if __name__ == '__main__': "1" "12:12:12" "coucou" - "INVALID command" + "first commandsecond command" "username" "realname" "UTF-8" @@ -2736,7 +2736,8 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='verify_cert']/dataform:value[text()='true']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='fingerprint']/dataform:value[text()='12:12:12']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-private'][@var='pass']/dataform:value[text()='coucou']", - "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='after_connect_command']/dataform:value[text()='INVALID command']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-multi'][@var='after_connect_commands']/dataform:value[text()='first command']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-multi'][@var='after_connect_commands']/dataform:value[text()='second command']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='username']/dataform:value[text()='username']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']/dataform:value[text()='realname']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']", @@ -2757,7 +2758,7 @@ if __name__ == '__main__': "" "" "" - "" + "" "" "" "" @@ -2770,7 +2771,7 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:title[text()='Configure the IRC server irc.localhost']", "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure the settings of the IRC server irc.localhost']", "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='pass']/dataform:value", - "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='after_connect_command']/dataform:value", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='after_connect_commands']/dataform:value", "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='username']/dataform:value", "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='realname']/dataform:value", "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='encoding_in']/dataform:value", -- cgit v1.2.3