Skip to content

Commit 4e457dc

Browse files
committed
Add in memory h2 database for tests
1 parent 56cf2fb commit 4e457dc

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ dependencies {
1717
implementation("org.springframework.boot:spring-boot-starter-security")
1818
implementation("org.springframework.boot:spring-boot-starter-web")
1919
implementation("org.mariadb.jdbc:mariadb-java-client:2.7.3")
20+
2021
developmentOnly("org.springframework.boot:spring-boot-devtools")
22+
2123
testImplementation("org.springframework.boot:spring-boot-starter-test")
2224
testImplementation("org.springframework.security:spring-security-test")
25+
testImplementation("com.h2database:h2")
2326
}
2427

2528

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
spring:
2+
jpa:
3+
hibernate:
4+
ddl-auto: none
5+
show-sql: true
6+
datasource:
7+
url: jdbc:h2:~/testdb;DB_CLOSE_ON_EXIT=FALSE
8+
username: user
9+
password: pass
10+
driver-class-name: org.h2.Driver
11+
security:
12+
oauth2:
13+
client:
14+
registration:
15+
discord:
16+
clientId: ${DDB_CLIENT_ID}
17+
clientSecret: ${DDB_CLIENT_SECRET}
18+
authorizationGrantType: authorization_code
19+
redirectUri: "{baseUrl}/login/oauth2/code/discord"
20+
scope: identify
21+
provider:
22+
discord:
23+
authorizationUri: https://discord.com/api/oauth2/authorize
24+
tokenUri: https://discord.com/api/oauth2/token
25+
26+

src/test/java/net/developerden/backend/controller/InfoControllerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
88
import org.springframework.boot.test.web.client.TestRestTemplate;
99
import org.springframework.boot.web.server.LocalServerPort;
10+
import org.springframework.test.context.ActiveProfiles;
1011

1112
import static org.assertj.core.api.Assertions.assertThat;
1213

14+
@ActiveProfiles("test")
1315
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
1416
public class InfoControllerTest {
1517

@@ -26,4 +28,4 @@ public void ping_happyDay_returnsPong() {
2628
String response = this.restTemplate.getForObject(baseUrl + "/ping", String.class);
2729
assertThat(response).isEqualTo("pong");
2830
}
29-
}
31+
}

0 commit comments

Comments
 (0)