1 #include "gtest/gtest.h"
2 #include "../include/manager.h"
3 #include "../include/library.h"
4 #include "../include/book.h"
5 #include <iostream>
6 #include <fstream>
7
TEST(ManagerTest,addBookFromPathAndGetIdTest)8 TEST(ManagerTest, addBookFromPathAndGetIdTest)
9 {
10 kiwix::Library lib;
11 kiwix::Manager manager = kiwix::Manager(&lib);
12
13 auto bookId = manager.addBookFromPathAndGetId("./test/example.zim");
14 EXPECT_NE(bookId, "");
15 kiwix::Book book = lib.getBookById(bookId);
16 EXPECT_EQ(book.getPath(), computeAbsolutePath("", "./test/example.zim"));
17
18 const std::string pathToSave = "./pathToSave";
19 const std::string url = "url";
20 bookId = manager.addBookFromPathAndGetId("./test/example.zim", pathToSave, url, true);
21 book = lib.getBookById(bookId);
22 auto savedPath = computeAbsolutePath(removeLastPathElement(manager.writableLibraryPath), pathToSave);
23 EXPECT_EQ(book.getPath(), savedPath);
24 EXPECT_EQ(book.getUrl(), url);
25 }