Skip to content

Commit

Permalink
chore: add testcontainers
Browse files Browse the repository at this point in the history
  • Loading branch information
h3nryc0ding committed Jan 31, 2024
1 parent 6904b46 commit 5577521
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ dependencies {
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
// Testing
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.testcontainers:mongodb")
testImplementation("org.testcontainers:junit-jupiter")

// Misc
implementation("com.netflix.graphql.dgs:graphql-dgs-webflux-starter")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package opensource.h3nryc0ding.playground

import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.testcontainers.service.connection.ServiceConnection
import org.testcontainers.containers.MongoDBContainer
import org.testcontainers.junit.jupiter.Container
import org.testcontainers.junit.jupiter.Testcontainers

@SpringBootTest
@Testcontainers
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class BackendApplicationTest {
companion object {
@Container
@ServiceConnection
val mongo = MongoDBContainer("mongo:latest")
}

@Test
fun contextLoads() {
}

@Test
fun `mongo is running`() {
assertTrue(mongo.isRunning)
}
}

0 comments on commit 5577521

Please sign in to comment.