Commit 0e62f945 authored by Ronan's avatar Ronan

feat(MainDb): rename tester

parent 303e9805
......@@ -24,6 +24,9 @@
#include "internal/c-tools.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
// =============================================================================
// Declare exported C types.
// =============================================================================
......
......@@ -22,10 +22,9 @@
#include <list>
#include "linphone/utils/utils.h"
#include <belle-sip/types.h>
// TODO: From coreapi. Remove me later.
#include "private.h"
#include "linphone/utils/utils.h"
#include "object/property-container.h"
......
......@@ -293,8 +293,8 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
*session << "SELECT notify_id, participant_address.value"
" FROM conference_notified_event, conference_participant_event, sip_address as participant_address"
" WHERE conference_participant_event.event_id = :eventId"
" AND conference_notified_event.event_id = conference_participant_event.event_id",
" AND participant_address.id = participant_address_id"
" AND conference_notified_event.event_id = conference_participant_event.event_id"
" AND participant_address.id = participant_address_id",
soci::into(notifyId), soci::into(participantAddress), soci::use(eventId);
// TODO: Use cache.
......
......@@ -199,8 +199,8 @@ set(SOURCE_FILES_CXX
conference-event-tester.cpp
conference-tester.cpp
cpim-tester.cpp
main-db-tester.cpp
multipart-tester.cpp
events-db-tester.cpp
property-container-tester.cpp
)
......
......@@ -49,7 +49,7 @@ extern test_suite_t conference_test_suite;
extern test_suite_t cpim_test_suite;
extern test_suite_t dtmf_test_suite;
extern test_suite_t event_test_suite;
extern test_suite_t events_db_test_suite;
extern test_suite_t main_db_test_suite;
extern test_suite_t flexisip_test_suite;
extern test_suite_t log_collection_test_suite;
extern test_suite_t message_test_suite;
......
/*
* events-db-tester.cpp
* main-db-tester.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
......@@ -36,52 +36,52 @@ static const string getDatabasePath () {
// -----------------------------------------------------------------------------
static void open_database () {
MainDb eventsDb;
BC_ASSERT_TRUE(eventsDb.connect(MainDb::Sqlite3, getDatabasePath()));
MainDb mainDb;
BC_ASSERT_TRUE(mainDb.connect(MainDb::Sqlite3, getDatabasePath()));
}
static void get_events_count () {
MainDb eventsDb;
BC_ASSERT_TRUE(eventsDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(eventsDb.getEventsCount(), 4976, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceCallFilter), 0, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceInfoFilter), 0, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::ConferenceChatMessageFilter), 4976, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getEventsCount(MainDb::NoFilter), 4976, int, "%d");
MainDb mainDb;
BC_ASSERT_TRUE(mainDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(mainDb.getEventsCount(), 4976, int, "%d");
BC_ASSERT_EQUAL(mainDb.getEventsCount(MainDb::ConferenceCallFilter), 0, int, "%d");
BC_ASSERT_EQUAL(mainDb.getEventsCount(MainDb::ConferenceInfoFilter), 0, int, "%d");
BC_ASSERT_EQUAL(mainDb.getEventsCount(MainDb::ConferenceChatMessageFilter), 4976, int, "%d");
BC_ASSERT_EQUAL(mainDb.getEventsCount(MainDb::NoFilter), 4976, int, "%d");
}
static void get_messages_count () {
MainDb eventsDb;
BC_ASSERT_TRUE(eventsDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(eventsDb.getMessagesCount(), 4976, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getMessagesCount("sip:test-7@sip.linphone.org"), 3, int, "%d");
MainDb mainDb;
BC_ASSERT_TRUE(mainDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(mainDb.getMessagesCount(), 4976, int, "%d");
BC_ASSERT_EQUAL(mainDb.getMessagesCount("sip:test-7@sip.linphone.org"), 3, int, "%d");
}
static void get_unread_messages_count () {
MainDb eventsDb;
BC_ASSERT_TRUE(eventsDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(eventsDb.getUnreadMessagesCount(), 2, int, "%d");
BC_ASSERT_EQUAL(eventsDb.getUnreadMessagesCount("sip:test-7@sip.linphone.org"), 0, int, "%d");
MainDb mainDb;
BC_ASSERT_TRUE(mainDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(mainDb.getUnreadMessagesCount(), 2, int, "%d");
BC_ASSERT_EQUAL(mainDb.getUnreadMessagesCount("sip:test-7@sip.linphone.org"), 0, int, "%d");
}
static void get_history () {
MainDb eventsDb;
BC_ASSERT_TRUE(eventsDb.connect(MainDb::Sqlite3, getDatabasePath()));
MainDb mainDb;
BC_ASSERT_TRUE(mainDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(
eventsDb.getHistory("sip:test-7@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceChatMessageFilter).size(),
mainDb.getHistory("sip:test-7@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceChatMessageFilter).size(),
3,
int,
"%d"
);
BC_ASSERT_EQUAL(
eventsDb.getHistory("sip:test-7@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceCallFilter).size(),
mainDb.getHistory("sip:test-7@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceCallFilter).size(),
0,
int,
"%d"
);
}
test_t events_db_tests[] = {
test_t main_db_tests[] = {
TEST_NO_TAG("Open database", open_database),
TEST_NO_TAG("Get events count", get_events_count),
TEST_NO_TAG("Get messages count", get_messages_count),
......@@ -89,7 +89,7 @@ test_t events_db_tests[] = {
TEST_NO_TAG("Get history", get_history)
};
test_suite_t events_db_test_suite = {
"EventsDb", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
sizeof(events_db_tests) / sizeof(events_db_tests[0]), events_db_tests
test_suite_t main_db_test_suite = {
"MainDb", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
sizeof(main_db_tests) / sizeof(main_db_tests[0]), main_db_tests
};
......@@ -574,7 +574,7 @@ void liblinphone_tester_add_suites() {
bc_tester_add_suite(&cpim_test_suite);
bc_tester_add_suite(&multipart_test_suite);
bc_tester_add_suite(&clonable_object_test_suite);
bc_tester_add_suite(&events_db_test_suite);
bc_tester_add_suite(&main_db_test_suite);
bc_tester_add_suite(&property_container_test_suite);
#if defined(VIDEO_ENABLED) && defined(HAVE_GTK)
bc_tester_add_suite(&video_test_suite);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment