Skip to content

Commit

Permalink
Mulighet for å kjøre lokalt med annen database enn via testcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasvinjevoll committed Oct 4, 2024
1 parent 02354ce commit 47a4cc5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/src/test/kotlin/no/nav/aap/brev/TestApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ import io.ktor.server.application.ApplicationStopped
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import no.nav.aap.brev.no.nav.aap.brev.test.Fakes
import no.nav.aap.komponenter.config.configForKey
import org.testcontainers.containers.PostgreSQLContainer
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy
import java.time.Duration
import java.time.temporal.ChronoUnit

fun main() {
val postgres = postgreSQLContainer()
var jdbcUrl = configForKey("JDBC_URL")

if (jdbcUrl == null) {
val postgres = postgreSQLContainer()
println("Bruk følgende konfigurasjon for å koble til databasen:")
println("jdbcUrl: ${postgres.jdbcUrl}. Password: ${postgres.password}. Username: ${postgres.username}.")
jdbcUrl = "${postgres.jdbcUrl}&user=${postgres.username}&password=${postgres.password}"
}

val fakes = Fakes(azurePort = 8081)

val dbConfig = DbConfig(
jdbcUrl = "${postgres.jdbcUrl}&user=${postgres.username}&password=${postgres.password}",
jdbcUrl = jdbcUrl,
)

println("Bruk følgende konfigurasjon for å koble til databasen:")
println("jdbcUrl: ${postgres.jdbcUrl}. Password: ${postgres.password}. Username: ${postgres.username}.")

// Starter server
embeddedServer(Netty, port = 8080) {
server(
Expand Down

0 comments on commit 47a4cc5

Please sign in to comment.