~singpolyma/biboumi

ref: 66887c225b63cecea62d17bcfae40cddef38c9d1 biboumi/tests/database.cpp -rw-r--r-- 851 bytes
66887c22 — Florent Le Coz Add a few tests 7 years ago
                                                                                
3c1889fb Florent Le Coz
66887c22 Florent Le Coz
3c1889fb Florent Le Coz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "catch.hpp"

#include <database/database.hpp>

#include <unistd.h>
#include <config/config.hpp>

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<db::IrcServerOptions>());

  b.update();
  CHECK(2 == Database::count<db::IrcServerOptions>());

  CHECK(b.pass == "");
  CHECK(b.pass.value() == "");

  Database::close();
#endif
}