Skip to content

Commit 085f748

Browse files
author
MohitMaliFtechiz
committed
Added test cases for checking is archive created with invalid zim file, added remove book from library by id tests
1 parent 4ee1e7f commit 085f748

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

lib/src/test/test.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public void testReader()
7171
assertEquals(new String(faviconData), c);
7272

7373
archive.dispose();
74+
75+
// test reader with invalid zim file
76+
String zimFile = "test.zim";
77+
try {
78+
Archive archive1 = new Archive(zimFile);
79+
fail("ERROR: Archive created with invalid Zim file!");
80+
} catch (ZimFileFormatException zimFileFormatException) {
81+
assertEquals("Cannot open zimfile " + zimFile, zimFileFormatException.getMessage());
82+
}
7483
}
7584

7685
@Test
@@ -147,11 +156,17 @@ public void testLibrary()
147156
String[] bookIds = lib.getBooksIds();
148157
assertEquals(bookIds.length, 1);
149158
lib.filter(new Filter().local(true));
150-
/*Book book = lib.getBookById(bookIds[0]);
151-
assertEquals(book.getTitle(), "Test ZIM file");
159+
//Book book = lib.getBookById(bookIds[0]);
160+
//System.out.println("books id book "+book);
161+
/*assertEquals(book.getTitle(), "Test ZIM file");
152162
assertEquals(book.getTags(), "unit;test");
153163
assertEquals(book.getIllustration(48).url(), "http://localhost/meta?name=favicon&content=small");
154164
assertEquals(book.getUrl(), "http://localhost/small.zim");*/
165+
166+
// remove book from library by id
167+
lib.removeBookById(bookIds[0]);
168+
bookIds = lib.getBooksIds();
169+
assertEquals(bookIds.length, 0);
155170
}
156171

157172
@Test

0 commit comments

Comments
 (0)