test: write tests for controllers #24
@@ -110,13 +110,11 @@ class FilmLibraryController(
|
||||
getFilmLibraryUseCase.getLibrary(
|
||||
GetFilmLibraryQuery(userId = userId),
|
||||
)
|
||||
}.getOrElse { exception ->
|
||||
if (exception is EntityNotFoundException) {
|
||||
null
|
||||
} else {
|
||||
}.onFailure { exception ->
|
||||
if (exception !is EntityNotFoundException) {
|
||||
throw exception
|
||||
}
|
||||
}
|
||||
}.getOrNull()
|
||||
|
||||
val allFilms = getAllFilmsUseCase.getAll()
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class FilmControllerSearchTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `search returns empty body when title is missing`() {
|
||||
fun `search returns 404 when title is not found`() {
|
||||
val title = "Unknown Title"
|
||||
|
||||
every { searchFilmByTitleUseCase.searchByTitle(title) } returns null
|
||||
@@ -68,7 +68,7 @@ class FilmControllerSearchTest {
|
||||
.get("/api/films/search") {
|
||||
param("title", title)
|
||||
}.andExpect {
|
||||
status { isOk() }
|
||||
status { isNotFound() }
|
||||
content { string("") }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user