mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #346 from kiwix/unit-test
This commit is contained in:
commit
8f07689c57
Binary file not shown.
|
@ -0,0 +1,25 @@
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
#include "../include/manager.h"
|
||||||
|
#include "../include/library.h"
|
||||||
|
#include "../include/book.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
TEST(ManagerTest, addBookFromPathAndGetIdTest)
|
||||||
|
{
|
||||||
|
kiwix::Library lib;
|
||||||
|
kiwix::Manager manager = kiwix::Manager(&lib);
|
||||||
|
|
||||||
|
auto bookId = manager.addBookFromPathAndGetId("./test/example.zim");
|
||||||
|
EXPECT_NE(bookId, "");
|
||||||
|
kiwix::Book book = lib.getBookById(bookId);
|
||||||
|
EXPECT_EQ(book.getPath(), computeAbsolutePath("", "./test/example.zim"));
|
||||||
|
|
||||||
|
const std::string pathToSave = "./pathToSave";
|
||||||
|
const std::string url = "url";
|
||||||
|
bookId = manager.addBookFromPathAndGetId("./test/example.zim", pathToSave, url, true);
|
||||||
|
book = lib.getBookById(bookId);
|
||||||
|
auto savedPath = computeAbsolutePath(removeLastPathElement(manager.writableLibraryPath), pathToSave);
|
||||||
|
EXPECT_EQ(book.getPath(), savedPath);
|
||||||
|
EXPECT_EQ(book.getUrl(), url);
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
|
configure_file(input : 'data/example.zim',
|
||||||
|
output : 'example.zim',
|
||||||
|
copy: true )
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
'parseUrl',
|
'parseUrl',
|
||||||
|
@ -8,7 +10,8 @@ tests = [
|
||||||
'stringTools',
|
'stringTools',
|
||||||
'pathTools',
|
'pathTools',
|
||||||
'kiwixserve',
|
'kiwixserve',
|
||||||
'book'
|
'book',
|
||||||
|
'manager'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue