From 6871172d57ac7356d30cb08b3c08d3bafe790275 Mon Sep 17 00:00:00 2001
From: Nico Athanassiadis <nico@dsv.su.se>
Date: Mon, 13 Jan 2025 12:39:46 +0100
Subject: [PATCH] Added testcontainers

Added testcontainers so we can run the tests without starting the db, since it's dockerized.
---
 pom.xml                                           | 15 +++++++++++++++
 .../se/su/dsv/seshat/SeshatApplicationTests.java  |  4 +++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 19f86ce..585143c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,6 +92,21 @@
             <artifactId>spring-security-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-testcontainers</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>mariadb</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/test/java/se/su/dsv/seshat/SeshatApplicationTests.java b/src/test/java/se/su/dsv/seshat/SeshatApplicationTests.java
index aa30243..1a1fb0c 100644
--- a/src/test/java/se/su/dsv/seshat/SeshatApplicationTests.java
+++ b/src/test/java/se/su/dsv/seshat/SeshatApplicationTests.java
@@ -2,10 +2,12 @@ package se.su.dsv.seshat;
 
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
 
 @SpringBootTest
 class SeshatApplicationTests {
-
+    @ServiceConnection
+    private static org.testcontainers.containers.MariaDBContainer<?> dbContainer = new org.testcontainers.containers.MariaDBContainer<>("mariadb:10.11");
     @Test
     void contextLoads() {
     }