Files
Sourcetrail/src/test/SqliteBookmarkStorageTestSuite.h
T
Eberhard Graether ff65a3f285 logic: Added update checker connecting to online API
* connects to https://www.sourcetrail.com/api/v1/versions/latest
* sends information about OS, platform, license type, current version and a unique user token
* Automatic update check is enabled via Startscreen and performed once every 24 hours on window focus
* Update check can be forced by clicking on "check for new version" on start screen
* renamed TimePoint to TimeStamp

fortune cookie message = In Träumen und im Leben ist nichts unmöglich.
2017-08-08 14:18:14 +02:00

111 lines
3.1 KiB
C++

#include "cxxtest/TestSuite.h"
#include "boost/filesystem.hpp"
#include "data/storage/sqlite/SqliteBookmarkStorage.h"
class SqliteBookmarkStorageTestSuite: public CxxTest::TestSuite
{
public:
void test_add_bookmarks()
{
FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite");
size_t bookmarkCount = 4;
int result = -1;
{
boost::filesystem::remove(databasePath.path());
SqliteBookmarkStorage storage(databasePath);
storage.setup();
for (size_t i = 0; i < bookmarkCount; i++)
{
const Id categoryId = storage.addBookmarkCategory("test category");
storage.addBookmark("test bookmark", "test comment", TimeStamp::now().toString(), categoryId);
}
result = storage.getAllBookmarks().size();
}
boost::filesystem::remove(databasePath.path());
TS_ASSERT_EQUALS(result, bookmarkCount);
}
void test_add_bookmarked_node()
{
FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite");
size_t bookmarkCount = 4;
int result = -1;
{
boost::filesystem::remove(databasePath.path());
SqliteBookmarkStorage storage(databasePath);
storage.setup();
const Id categoryId = storage.addBookmarkCategory("test category");
const Id bookmarkId = storage.addBookmark("test bookmark", "test comment", TimeStamp::now().toString(), categoryId);
for (size_t i = 0; i < bookmarkCount; i++)
{
storage.addBookmarkedNode(bookmarkId, "test name");
}
result = storage.getAllBookmarkedNodes().size();
}
boost::filesystem::remove(databasePath.path());
TS_ASSERT_EQUALS(result, bookmarkCount);
}
void test_remove_bookmark_also_removes_bookmarked_node()
{
FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite");
int result = -1;
{
boost::filesystem::remove(databasePath.path());
SqliteBookmarkStorage storage(databasePath);
storage.setup();
const Id categoryId = storage.addBookmarkCategory("test category");
const Id bookmarkId = storage.addBookmark("test bookmark", "test comment", TimeStamp::now().toString(), categoryId);
storage.addBookmarkedNode(bookmarkId, "test name");
storage.removeBookmark(bookmarkId);
result = storage.getAllBookmarkedNodes().size();
}
boost::filesystem::remove(databasePath.path());
TS_ASSERT_EQUALS(result, 0);
}
void test_edit_nodeBookmark()
{
FilePath databasePath("data/SQLiteTestSuite/bookmarkTest.sqlite");
const std::string updatedName = "updated name";
const std::string updatedComment = "updated comment";
StorageBookmark storageBookmark;
{
boost::filesystem::remove(databasePath.path());
SqliteBookmarkStorage storage(databasePath);
storage.setup();
const Id categoryId = storage.addBookmarkCategory("test category");
const Id bookmarkId = storage.addBookmark("test bookmark", "test comment", TimeStamp::now().toString(), categoryId);
storage.addBookmarkedNode(bookmarkId, "test name");
storage.updateBookmark(bookmarkId, updatedName, updatedComment, categoryId);
storageBookmark = storage.getAllBookmarks().front();
}
boost::filesystem::remove(databasePath.path());
TS_ASSERT_EQUALS(updatedName, storageBookmark.name);
TS_ASSERT_EQUALS(updatedComment, storageBookmark.comment);
}
};