diff tests/libserver/dao-account/main.cpp @ 39:56ab2f0c90dc

Server: add sqlite basic backend, closes #558
author David Demelier <markand@malikania.fr>
date Sun, 27 Nov 2016 18:00:49 +0100
parents d4f5f7231b84
children a47a4477f347
line wrap: on
line diff
--- a/tests/libserver/dao-account/main.cpp	Sat Nov 05 16:29:32 2016 +0100
+++ b/tests/libserver/dao-account/main.cpp	Sun Nov 27 18:00:49 2016 +0100
@@ -28,74 +28,7 @@
 
 using namespace malikania;
 
-class TestAccountDao : public testing::Test {
-protected:
-    Database m_database;
-    AccountDao m_dao;
-
-public:
-    TestAccountDao()
-        : m_database(DRIVERDIR "pgsql.so", {
-            { "host", WITH_TEST_PGSQL_HOST },
-            { "port", WITH_TEST_PGSQL_PORT },
-            { "user", WITH_TEST_PGSQL_USER },
-            { "database", WITH_TEST_PGSQL_DATABASE }
-        })
-        , m_dao(m_database)
-    {
-        m_dao.clear();
-
-        assert(m_dao.count() == 0U);
-    }
-};
-
-TEST_F(TestAccountDao, create)
-{
-    try {
-        Account ac;
-
-        ac.setName("jean");
-        ac.setEmail("jean@christophe.fr");
-        ac.setFirstName("Jean");
-        ac.setLastName("Christophe");
-        ac.setPassword("raw");
-
-        m_dao.create(ac);
-
-        ASSERT_EQ(1U, m_dao.count());
-        ASSERT_EQ(ac, m_dao.list()[0]);
-    } catch (const std::exception &ex) {
-        FAIL() << ex.what();
-    }
-}
-
-TEST_F(TestAccountDao, update)
-{
-    try {
-        Account ac;
-
-        ac.setName("jean");
-        ac.setEmail("jean@christophe.fr");
-        ac.setFirstName("Jean");
-        ac.setLastName("Christophe");
-        ac.setPassword("raw");
-
-        m_dao.create(ac);
-
-        ac.setEmail("benoit@christophe.fr");
-        ac.setFirstName("Benoit");
-
-        m_dao.update(ac);
-
-        Account ac2 = m_dao.get(ac.id());
-
-        ASSERT_EQ("jean", ac2.name());
-        ASSERT_EQ("benoit@christophe.fr", ac2.email());
-        ASSERT_EQ("Benoit", ac2.firstName());
-    } catch (const std::exception &ex) {
-        FAIL() << ex.what();
-    }
-}
+#include "test-sqlite.hpp"
 
 int main(int argc, char **argv)
 {