Add test 404 for GetArticle route
This commit is contained in:
@@ -14,10 +14,8 @@ import java.util.concurrent.CompletionException
|
|||||||
|
|
||||||
class HttpError(
|
class HttpError(
|
||||||
statusCode: HttpStatusCode,
|
statusCode: HttpStatusCode,
|
||||||
val cause: Throwable? = null,
|
cause: Throwable? = null,
|
||||||
val type: String? = null,
|
|
||||||
val title: String = cause?.message ?: statusCode.description,
|
val title: String = cause?.message ?: statusCode.description,
|
||||||
val detail: String? = null,
|
|
||||||
) {
|
) {
|
||||||
val statusCode: Int = statusCode.value
|
val statusCode: Int = statusCode.value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,13 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/400'
|
$ref: '#/components/schemas/400'
|
||||||
|
404:
|
||||||
|
description: BadReqest
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/404'
|
||||||
|
|
||||||
/articles/{article}/versions:
|
/articles/{article}/versions:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/article'
|
- $ref: '#/components/parameters/article'
|
||||||
@@ -2278,7 +2285,7 @@ components:
|
|||||||
example: MASTER
|
example: MASTER
|
||||||
|
|
||||||
400:
|
400:
|
||||||
description: noting
|
description: Bad Request
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
- invalidParams
|
- invalidParams
|
||||||
@@ -2304,6 +2311,20 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
example: 'Cannot be null'
|
example: 'Cannot be null'
|
||||||
|
|
||||||
|
404:
|
||||||
|
description: Not Found
|
||||||
|
required:
|
||||||
|
- title
|
||||||
|
- statusCode
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
statusCode:
|
||||||
|
type: integer
|
||||||
|
example: 404
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
example: Bad Request
|
||||||
|
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
JWTAuth:
|
JWTAuth:
|
||||||
type: http
|
type: http
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import integration.steps.then.`which contains`
|
|||||||
import integration.steps.then.and
|
import integration.steps.then.and
|
||||||
import io.ktor.http.HttpStatusCode.Companion.BadRequest
|
import io.ktor.http.HttpStatusCode.Companion.BadRequest
|
||||||
import io.ktor.http.HttpStatusCode.Companion.Forbidden
|
import io.ktor.http.HttpStatusCode.Companion.Forbidden
|
||||||
|
import io.ktor.http.HttpStatusCode.Companion.NotFound
|
||||||
import io.ktor.http.HttpStatusCode.Companion.OK
|
import io.ktor.http.HttpStatusCode.Companion.OK
|
||||||
import org.junit.jupiter.api.Tag
|
import org.junit.jupiter.api.Tag
|
||||||
import org.junit.jupiter.api.Tags
|
import org.junit.jupiter.api.Tags
|
||||||
@@ -82,6 +83,17 @@ class `Article routes` : BaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `I cannot get article with id doesn't exist`() {
|
||||||
|
withIntegrationApplication {
|
||||||
|
`When I send a GET request`("/articles/635fe2e8-2dbc-4c80-b306-101d38a4ab23") `Then the response should be` NotFound and {
|
||||||
|
`And the response should not be null`()
|
||||||
|
`And the response should contain`("$.title", "Article 635fe2e8-2dbc-4c80-b306-101d38a4ab23 not found")
|
||||||
|
`And the response should contain`("$.statusCode", 404)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Tag("BadRequest")
|
@Tag("BadRequest")
|
||||||
fun `I cannot get article by id with wrong id format`() {
|
fun `I cannot get article by id with wrong id format`() {
|
||||||
|
|||||||
Reference in New Issue
Block a user