Fix flyway migration and use h2 in unit tests.
All checks were successful
Backend CI / Run Maven Tests (pull_request) Successful in 1m21s

This commit is contained in:
2025-08-07 19:04:21 +03:00
parent 2e14ea06c9
commit b04366163f
6 changed files with 108 additions and 20 deletions

View File

@@ -74,6 +74,12 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<!-- JSON Processing -->
<dependency>
@@ -132,4 +138,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View File

@@ -1,5 +1,18 @@
CREATE SCHEMA IF NOT EXISTS vibing;
CREATE TABLE IF NOT EXISTS vibing.locations (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
address TEXT,
city TEXT,
country TEXT,
postal_code TEXT,
latitude DOUBLE PRECISION,
longitude DOUBLE PRECISION,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS vibing.activities (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
@@ -20,17 +33,3 @@ CREATE TABLE IF NOT EXISTS vibing.activity_tags (
FOREIGN KEY (activity_id) REFERENCES vibing.activities(id) ON DELETE CASCADE,
PRIMARY KEY (activity_id, tag)
);
CREATE TABLE IF NOT EXISTS vibing.locations (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
address TEXT,
city TEXT,
country TEXT,
postal_code TEXT,
latitude DOUBLE PRECISION,
longitude DOUBLE PRECISION,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View File

@@ -2,15 +2,17 @@ package com.vibing.backend;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
/**
* Basic test class for the Vibing Backend application.
*/
@SpringBootTest
@ActiveProfiles("test")
class VibingBackendApplicationTests {
@Test
void contextLoads() {
// This test verifies that the Spring application context loads successfully
}
}
}

View File

@@ -1,10 +1,21 @@
spring:
datasource:
url: jdbc:postgresql://localhost:5432/your_test_database
username: test_user
password: test_password
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL
username: sa
password:
driver-class-name: org.h2.Driver
h2:
console:
enabled: true
jpa:
hibernate:
ddl-auto: none # Let Flyway handle schema creation
show-sql: true
database-platform: org.hibernate.dialect.H2Dialect
flyway:
enabled: true
clean-disabled: false # Allow clean in tests
locations: classpath:db/migration
locations: classpath:db/migration