-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix category reorder Endpoint. Added Test for Category Reorder (#232)
* Fix category reorder Endpoint. Added Test for Category Reorder * Remove streams and use kotlin filtering
- Loading branch information
Showing
2 changed files
with
52 additions
and
2 deletions.
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
48 changes: 48 additions & 0 deletions
48
server/src/test/kotlin/suwayomi/tachidesk/manga/controller/CategoryControllerTest.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,48 @@ | ||
package suwayomi.tachidesk.manga.controller | ||
|
||
import org.jetbrains.exposed.sql.deleteAll | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import suwayomi.BASE_PATH | ||
import suwayomi.tachidesk.manga.impl.Category | ||
import suwayomi.tachidesk.manga.model.table.CategoryTable | ||
import suwayomi.tachidesk.server.applicationSetup | ||
import xyz.nulldev.ts.config.CONFIG_PREFIX | ||
import java.io.File | ||
|
||
internal class CategoryControllerTest { | ||
|
||
@BeforeEach | ||
internal fun setUp() { | ||
val dataRoot = File(BASE_PATH).absolutePath | ||
System.setProperty("$CONFIG_PREFIX.server.rootDir", dataRoot) | ||
applicationSetup() | ||
} | ||
|
||
@Test | ||
fun categoryReorder() { | ||
Category.createCategory("foo") | ||
Category.createCategory("bar") | ||
val cats = Category.getCategoryList() | ||
val foo = cats.asSequence().filter { it.name == "foo" }.first() | ||
val bar = cats.asSequence().filter { it.name == "bar" }.first() | ||
assertEquals(1, foo.order) | ||
assertEquals(2, bar.order) | ||
Category.reorderCategory(1, 2) | ||
val catsReordered = Category.getCategoryList() | ||
val fooReordered = catsReordered.asSequence().filter { it.name == "foo" }.first() | ||
val barReordered = catsReordered.asSequence().filter { it.name == "bar" }.first() | ||
assertEquals(2, fooReordered.order) | ||
assertEquals(1, barReordered.order) | ||
} | ||
|
||
@AfterEach | ||
internal fun tearDown() { | ||
transaction { | ||
CategoryTable.deleteAll() | ||
} | ||
} | ||
} |