File tree Expand file tree Collapse file tree 4 files changed +47
-7
lines changed
testFixtures/kotlin/com/gotchai/api/docs
test/kotlin/com/gotchai/api/presentation/v1/exam Expand file tree Collapse file tree 4 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 11import com.epages.restdocs.apispec.gradle.OpenApi3Task
2+ import groovy.lang.Closure
3+ import io.swagger.v3.oas.models.servers.Server
24
35plugins {
46 alias(libs.plugins.restdocs.api.spec)
@@ -47,17 +49,36 @@ tasks {
4749 finalizedBy(withType<OpenApi3Task >())
4850 }
4951
52+ withType<OpenApi3Task > {
53+ doFirst {
54+ val outputDir = file(" src/main/resources/static/docs" )
55+ if (! outputDir.exists()) {
56+ outputDir.mkdirs()
57+ }
58+ }
59+ }
60+
5061 jib {
5162 from {
5263 image = " amazoncorretto:21-alpine"
5364 }
5465 }
66+ }
5567
56- openapi3 {
57- title = " Gotchai API"
58- version = " v1"
59- format = " yml"
60- outputFileNamePrefix = " api"
61- outputDirectory = " src/main/resources/static/docs"
62- }
68+ openapi3 {
69+ title = " Gotchai API"
70+ version = " v1"
71+ format = " yml"
72+ outputFileNamePrefix = " api"
73+ outputDirectory = " src/main/resources/static/docs"
74+ setServers(
75+ listOf (
76+ " https://dev-api.gotchai-ai.com" ,
77+ " http://localhost:8080" ,
78+ ).map { url ->
79+ object : Closure <Server >(this ) {
80+ fun doCall (): Server = Server ().apply { this .url = url }
81+ }
82+ },
83+ )
6384}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import com.gotchai.domain.global.exception.NotFoundDataException
1818import com.ninjasquad.springmockk.MockkBean
1919import io.mockk.every
2020import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
21+ import org.springframework.restdocs.payload.PayloadDocumentation.responseBody
2122import org.springframework.test.web.reactive.server.expectBody
2223
2324@WebMvcTest(ExamController ::class )
@@ -49,6 +50,20 @@ class ExamControllerTest : ControllerTest() {
4950 }
5051 }
5152 }
53+
54+ context(" 시험 목록이 비어있는 경우" ) {
55+ every { examQueryUseCase.getExams() } returns emptyList()
56+
57+ it(" 상태 코드 200과 빈 리스트를 반환한다." ) {
58+ webClient
59+ .get()
60+ .uri(" /api/v1/exams" )
61+ .exchange()
62+ .expectStatus()
63+ .isOk
64+ .expectBody<ApiResponse <ExamListResponse >>()
65+ }
66+ }
5267 }
5368
5469 describe(" getExamById()는" ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ val apiResponseFields =
99 fieldsOf(
1010 ApiResponse <* >::isSuccess bodyDesc " 처리 성공 여부" ,
1111 ApiResponse <* >::status bodyDesc " 상태 코드" ,
12+ ApiResponse <* >::data bodyDesc " 응답 데이터" ,
1213 ApiResponse <* >::timestamp bodyDesc " 타임 스탬프"
1314 )
1415
Original file line number Diff line number Diff line change @@ -77,4 +77,7 @@ subprojects {
7777 classpath + = files(sourceSets.main.map { it.output })
7878 }
7979 }
80+
81+
82+
8083}
You can’t perform that action at this time.
0 commit comments