Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.boot:spring-boot-starter-flyway")
implementation("org.springframework.boot:spring-boot-starter-webmvc")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("com.mysql:mysql-connector-j")
implementation("org.flywaydb:flyway-mysql")
implementation("org.jetbrains.kotlin:kotlin-reflect")
Expand All @@ -42,6 +43,7 @@ dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-data-jdbc-test")
testImplementation("org.springframework.boot:spring-boot-starter-flyway-test")
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testcontainers:junit-jupiter:1.21.4")
testImplementation("org.testcontainers:mysql:1.21.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ spring.datasource.url=jdbc:mysql://localhost:3306/${DB_NAME:mydatabase}
spring.datasource.username=${DB_USER:user}
spring.datasource.password=${DB_PASSWORD:secret}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Actuator Health
management.endpoints.web.exposure.include=health,info
management.endpoint.health.probes.enabled=true
management.endpoint.health.show-details=never
29 changes: 29 additions & 0 deletions src/test/kotlin/com/wafflestudio/team2server/HelathrouteTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.wafflestudio.team2server

import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import org.testcontainers.junit.jupiter.Testcontainers

@SpringBootTest
@ActiveProfiles("test")
@Testcontainers
@AutoConfigureMockMvc
class HelathrouteTests(
@Autowired private val mvc: MockMvc,
) {
@Test
fun health_is_up() {
// healthroute 정상작동한다
mvc
.perform(get("/actuator/health"))
.andExpect(status().isOk)
.andExpect(jsonPath("$.status").value("UP"))
}
}