From 3c1889fbd0d7b96aae16f3479ac8aae70a7e15f7 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 28 Oct 2015 19:13:53 +0100 Subject: Use Catch for our test suite `make check` is also added to compile and run the tests Catch is fetched with cmake automatically into the build directory when needed --- tests/database.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/database.cpp (limited to 'tests/database.cpp') diff --git a/tests/database.cpp b/tests/database.cpp new file mode 100644 index 0000000..fd9e873 --- /dev/null +++ b/tests/database.cpp @@ -0,0 +1,30 @@ +#include "catch.hpp" + +#include + +#include +#include + +TEST_CASE("Database") +{ +#ifdef USE_DATABASE + // Remove any potential existing db + ::unlink("./test.db"); + Config::set("db_name", "test.db"); + Database::set_verbose(false); + auto o = Database::get_irc_server_options("zouzou@example.com", "irc.example.com"); + o.update(); + 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()); + + b.update(); + CHECK(2 == Database::count()); + + CHECK(b.pass == ""); + CHECK(b.pass.value() == ""); +#endif +} -- cgit v1.2.3