Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyunk3l committed Dec 5, 2021
1 parent 54e2b1d commit 2b6afe8
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
package [[group_name]].[[project_name]].componenttest

import [[group_name]].[[project_name]].Application
import [[group_name]].[[project_name]].Application
import [[group_name]].[[project_name]].infrastructure.adapters.outbound.postgres.DatabaseContainer
import org.junit.jupiter.api.Tag
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.web.server.LocalServerPort
import org.springframework.test.context.DynamicPropertyRegistry
import org.springframework.test.context.DynamicPropertySource
import org.testcontainers.junit.jupiter.Testcontainers

@Suppress("UnnecessaryAbstractClass")
@Tag("component")
@Testcontainers
@SpringBootTest(classes = [Application::class], webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
abstract class BaseComponentTest {

@LocalServerPort
val servicePort: Int = 0

companion object {

@JvmStatic
@DynamicPropertySource
fun postgresProperties(registry: DynamicPropertyRegistry) {
val postgresContainer = DatabaseContainer.postgresContainer
registry.add("spring.datasource.url", postgresContainer::getJdbcUrl)
registry.add("spring.datasource.username", postgresContainer::getUsername)
registry.add("spring.datasource.password", postgresContainer::getPassword)
}
}
}

0 comments on commit 2b6afe8

Please sign in to comment.