Files
sodalive-backend-spring-boot/src/test/kotlin/kr/co/vividnext/sodalive/deployment/DeploymentEndpointInjectedValueIntegrationTest.kt
T

51 lines
2.0 KiB
Kotlin

package kr.co.vividnext.sodalive.deployment
import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.boot.test.web.server.LocalManagementPort
import org.springframework.http.HttpStatus
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.ContextConfiguration
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = [
"management.server.port=0",
"deployment.artifact-version=1.2.3-20260914",
"deployment.config-commit=1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d",
"spring.datasource.url=jdbc:h2:mem:deployment-endpoint-injected-integration;" +
"MODE=MySQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=VALUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"
]
)
@ContextConfiguration(initializers = [EmbeddedRedisInitializer::class])
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class DeploymentEndpointInjectedValueIntegrationTest @Autowired constructor(
private val restTemplate: TestRestTemplate
) {
@LocalManagementPort
private var managementPort: Int = 0
@Test
@DisplayName("배포 식별자가 주입되면 /actuator/deployment는 주입된 값을 반환한다")
fun shouldReturnInjectedDeploymentIdentity() {
val response = restTemplate.getForEntity(
"http://localhost:$managementPort/actuator/deployment",
Map::class.java
)
assertEquals(HttpStatus.OK, response.statusCode)
assertEquals(
mapOf(
"application_artifact_version" to "1.2.3-20260914",
"config_commit" to "1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d"
),
response.body
)
}
}