forked from Suwayomi/Suwayomi-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Manga Meta, add Manga Meta test (Suwayomi#245)
* Fix Manga Meta, add Manga Meta test * Tweak assertion strings
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
server/src/test/kotlin/suwayomi/tachidesk/manga/impl/MangaTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package suwayomi.tachidesk.manga.impl | ||
|
||
/* | ||
* Copyright (C) Contributors to the Suwayomi project | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.TestInstance | ||
import suwayomi.tachidesk.manga.model.table.MangaMetaTable | ||
import suwayomi.tachidesk.manga.model.table.MangaTable | ||
import suwayomi.tachidesk.test.ApplicationTest | ||
import suwayomi.tachidesk.test.clearTables | ||
import suwayomi.tachidesk.test.createLibraryManga | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class MangaTest : ApplicationTest() { | ||
@Test | ||
fun getMangaMeta() { | ||
val metaManga = createLibraryManga("META_TEST") | ||
val emptyMeta = Manga.getMangaMetaMap(metaManga).size | ||
assertEquals(0, emptyMeta, "Default Manga meta should be empty at start") | ||
|
||
Manga.modifyMangaMeta(metaManga, "test", "value") | ||
assertEquals(1, Manga.getMangaMetaMap(metaManga).size, "Manga meta should have one member") | ||
assertEquals("value", Manga.getMangaMetaMap(metaManga)["test"], "Manga meta use the value 'value' for key 'test'") | ||
|
||
Manga.modifyMangaMeta(metaManga, "test", "newValue") | ||
assertEquals( | ||
1, | ||
Manga.getMangaMetaMap(metaManga).size, | ||
"Manga meta should still only have one pair" | ||
) | ||
assertEquals( | ||
"newValue", Manga.getMangaMetaMap(metaManga)["test"], | ||
"Manga meta with key 'test' should use the value `newValue`" | ||
) | ||
|
||
Manga.modifyMangaMeta(metaManga, "test2", "value2") | ||
assertEquals( | ||
2, Manga.getMangaMetaMap(metaManga).size, | ||
"Manga Meta should have an additional pair" | ||
) | ||
assertEquals( | ||
"value2", Manga.getMangaMetaMap(metaManga)["test2"], | ||
"Manga Meta for key 'test2' should be 'value2'" | ||
) | ||
} | ||
|
||
@AfterEach | ||
internal fun tearDown() { | ||
clearTables( | ||
MangaMetaTable, | ||
MangaTable | ||
) | ||
} | ||
} |