summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-06-28 14:42:33 +0200
committerlouiz’ <louiz@louiz.org>2017-06-28 14:42:33 +0200
commitc5407cf8ce6add6f3534df41398235e93b605ab3 (patch)
treef62cccb758dde48270cc24257df36bd3f5f89cf8 /tests
parent13a1ab1878fd6312aea485ded3f5bad59c36f17f (diff)
parentb71ca15a0f9114db38eec23b49d1489a2ff1d0ca (diff)
downloadbiboumi-c5407cf8ce6add6f3534df41398235e93b605ab3.tar.gz
biboumi-c5407cf8ce6add6f3534df41398235e93b605ab3.tar.bz2
biboumi-c5407cf8ce6add6f3534df41398235e93b605ab3.tar.xz
biboumi-c5407cf8ce6add6f3534df41398235e93b605ab3.zip
Merge branch 'master' into debian
Diffstat (limited to 'tests')
-rw-r--r--tests/database.cpp50
-rw-r--r--tests/end_to_end/__main__.py6
-rw-r--r--tests/end_to_end/ircd.conf2
3 files changed, 31 insertions, 27 deletions
diff --git a/tests/database.cpp b/tests/database.cpp
index 4e2be14..f49220a 100644
--- a/tests/database.cpp
+++ b/tests/database.cpp
@@ -8,24 +8,22 @@ TEST_CASE("Database")
{
#ifdef USE_DATABASE
Database::open(":memory:");
- Database::set_verbose(false);
SECTION("Basic retrieve and update")
{
auto o = Database::get_irc_server_options("zouzou@example.com", "irc.example.com");
- o.update();
+ o.save(Database::db);
auto a = Database::get_irc_server_options("zouzou@example.com", "irc.example.com");
auto b = Database::get_irc_server_options("moumou@example.com", "irc.example.com");
// b does not yet exist in the db, the object is created but not yet
// inserted
- CHECK(1 == Database::count<db::IrcServerOptions>());
+ CHECK(1 == Database::count(Database::irc_server_options));
- b.update();
- CHECK(2 == Database::count<db::IrcServerOptions>());
+ b.save(Database::db);
+ CHECK(2 == Database::count(Database::irc_server_options));
- CHECK(b.pass == "");
- CHECK(b.pass.value() == "");
+ CHECK(b.col<Database::Pass>() == "");
}
SECTION("channel options")
@@ -33,16 +31,20 @@ TEST_CASE("Database")
Config::set("db_name", ":memory:");
auto o = Database::get_irc_channel_options("zouzou@example.com", "irc.example.com", "#foo");
- CHECK(o.encodingIn == "");
- o.encodingIn = "ISO-8859-1";
- o.update();
+ CHECK(o.col<Database::EncodingIn>() == "");
+ o.col<Database::EncodingIn>() = "ISO-8859-1";
+ CHECK(o.col<Database::RecordHistoryOptional>().is_set == false);
+ o.col<Database::RecordHistoryOptional>().set_value(false);
+ o.save(Database::db);
auto b = Database::get_irc_channel_options("zouzou@example.com", "irc.example.com", "#foo");
- CHECK(o.encodingIn == "ISO-8859-1");
+ CHECK(o.col<Database::EncodingIn>() == "ISO-8859-1");
+ CHECK(o.col<Database::RecordHistoryOptional>().is_set == true);
+ CHECK(o.col<Database::RecordHistoryOptional>().value == false);
}
SECTION("Channel options with server default")
{
- const std::string owner{"zouzou@example.com"};
+ const std::string owner{"CACA@example.com"};
const std::string server{"irc.example.com"};
const std::string chan1{"#foo"};
@@ -51,43 +53,43 @@ TEST_CASE("Database")
GIVEN("An option defined for the channel but not the server")
{
- c.encodingIn = "channelEncoding";
- c.update();
+ c.col<Database::EncodingIn>() = "channelEncoding";
+ c.save(Database::db);
WHEN("we fetch that option")
{
auto r = Database::get_irc_channel_options_with_server_default(owner, server, chan1);
THEN("we get the channel option")
- CHECK(r.encodingIn == "channelEncoding");
+ CHECK(r.col<Database::EncodingIn>() == "channelEncoding");
}
}
GIVEN("An option defined for the server but not the channel")
{
- s.encodingIn = "serverEncoding";
- s.update();
+ s.col<Database::EncodingIn>() = "serverEncoding";
+ s.save(Database::db);
WHEN("we fetch that option")
{
auto r = Database::get_irc_channel_options_with_server_default(owner, server, chan1);
THEN("we get the server option")
- CHECK(r.encodingIn == "serverEncoding");
+ CHECK(r.col<Database::EncodingIn>() == "serverEncoding");
}
}
GIVEN("An option defined for both the server and the channel")
{
- s.encodingIn = "serverEncoding";
- s.update();
- c.encodingIn = "channelEncoding";
- c.update();
+ s.col<Database::EncodingIn>() = "serverEncoding";
+ s.save(Database::db);
+ c.col<Database::EncodingIn>() = "channelEncoding";
+ c.save(Database::db);
WHEN("we fetch that option")
{
auto r = Database::get_irc_channel_options_with_server_default(owner, server, chan1);
THEN("we get the channel option")
- CHECK(r.encodingIn == "channelEncoding");
+ CHECK(r.col<Database::EncodingIn>() == "channelEncoding");
}
WHEN("we fetch that option, with no channel specified")
{
auto r = Database::get_irc_channel_options_with_server_default(owner, server, "");
THEN("we get the server option")
- CHECK(r.encodingIn == "serverEncoding");
+ CHECK(r.col<Database::EncodingIn>() == "serverEncoding");
}
}
}
diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py
index f9e04a8..19dc270 100644
--- a/tests/end_to_end/__main__.py
+++ b/tests/end_to_end/__main__.py
@@ -278,7 +278,6 @@ def expect_stanza(xpaths, xmpp, biboumi, optional=False, after=None):
def save_current_timestamp_plus_delta(key, delta, message, xmpp):
now_plus_delta = datetime.datetime.utcnow() + delta
xmpp.saved_values[key] = now_plus_delta.strftime("%FT%T.967Z")
- print(xmpp.saved_values[key])
def sleep_for(duration, xmpp, biboumi):
time.sleep(duration)
@@ -2417,7 +2416,7 @@ if __name__ == '__main__':
"/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']",
- "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='ISO-8859-1']",
+ "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']",
"/iq/commands:command/commands:actions/commands:next",
),
after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid"))
@@ -2467,6 +2466,7 @@ if __name__ == '__main__':
partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='configure'][@sessionid][@status='executing']",
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']",
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']",
+ "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='list-single'][@var='record_history']/dataform:value[text()='unset']",
),
after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid"))
),
@@ -2476,6 +2476,7 @@ if __name__ == '__main__':
"<field var='ports' />"
"<field var='encoding_out'><value>UTF-8</value></field>"
"<field var='encoding_in'><value>latin-1</value></field>"
+ "<field var='record_history'><value>true</value></field>"
"</x></command></iq>"),
partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"),
@@ -2484,6 +2485,7 @@ if __name__ == '__main__':
"/iq/commands:command/dataform:x[@type='form']/dataform:title[text()='Configure the IRC channel #foo on server irc.localhost']",
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']",
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']",
+ "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='list-single'][@var='record_history']/dataform:value[text()='true']",
"/iq/commands:command/commands:actions/commands:next",
),
after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid"))
diff --git a/tests/end_to_end/ircd.conf b/tests/end_to_end/ircd.conf
index cdb06d5..ccfbd90 100644
--- a/tests/end_to_end/ircd.conf
+++ b/tests/end_to_end/ircd.conf
@@ -498,7 +498,7 @@ general {
reject_after_count = 3;
reject_duration = 5 minutes;
throttle_duration = 60;
- throttle_count = 4;
+ throttle_count = 8888;
max_ratelimit_tokens = 30;
away_interval = 30;
certfp_method = sha1;