Phase 1 work
This commit is contained in:
@@ -17,7 +17,9 @@ fun main() {
|
||||
}
|
||||
|
||||
@Serializable
|
||||
private data class Health(val status: String)
|
||||
private data class Health(
|
||||
val status: String,
|
||||
)
|
||||
|
||||
fun Application.module() {
|
||||
install(ContentNegotiation) {
|
||||
|
||||
@@ -8,14 +8,24 @@ object Database {
|
||||
private val log = LoggerFactory.getLogger(Database::class.java)
|
||||
|
||||
fun migrate(app: Application) {
|
||||
val url = app.environment.config.property("database.url").getString()
|
||||
val user = app.environment.config.property("database.user").getString()
|
||||
val password = app.environment.config.property("database.password").getString()
|
||||
val url =
|
||||
app.environment.config
|
||||
.property("database.url")
|
||||
.getString()
|
||||
val user =
|
||||
app.environment.config
|
||||
.property("database.user")
|
||||
.getString()
|
||||
val password =
|
||||
app.environment.config
|
||||
.property("database.password")
|
||||
.getString()
|
||||
|
||||
log.info("Connecting to {} as {} and running Flyway migrations", url, user)
|
||||
|
||||
runCatching {
|
||||
Flyway.configure()
|
||||
Flyway
|
||||
.configure()
|
||||
.dataSource(url, user, password)
|
||||
.locations("classpath:db/migration")
|
||||
.baselineOnMigrate(true)
|
||||
|
||||
@@ -12,19 +12,19 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ApplicationTest {
|
||||
|
||||
@Test
|
||||
fun `health endpoint returns 200 with status ok`() = testApplication {
|
||||
application {
|
||||
install(ContentNegotiation) {
|
||||
json()
|
||||
fun `health endpoint returns 200 with status ok`() =
|
||||
testApplication {
|
||||
application {
|
||||
install(ContentNegotiation) {
|
||||
json()
|
||||
}
|
||||
configureRouting()
|
||||
}
|
||||
configureRouting()
|
||||
val response = client.get("/health")
|
||||
assertEquals(HttpStatusCode.OK, response.status)
|
||||
val body = response.bodyAsText()
|
||||
assertTrue(body.contains("\"status\""), "expected body to contain status field, was: $body")
|
||||
assertTrue(body.contains("\"ok\""), "expected body to contain ok value, was: $body")
|
||||
}
|
||||
val response = client.get("/health")
|
||||
assertEquals(HttpStatusCode.OK, response.status)
|
||||
val body = response.bodyAsText()
|
||||
assertTrue(body.contains("\"status\""), "expected body to contain status field, was: $body")
|
||||
assertTrue(body.contains("\"ok\""), "expected body to contain ok value, was: $body")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user