Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/develop_build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ jobs:
java-version: '17'
distribution: 'temurin'

# 테스트 환경에서 필요한 컨테이너 실행 (redis, postgres)
- name: Run Containers
run: docker compose -f ./docker-compose-test.yml up -d

# 테스트 환경에서 필요한 스키마, 데이터 등록
- name: Apply Schema and Data
run: |
echo "${{ secrets.SCHEMA_SQL }}" > src/test/resources/test-schema.sql
echo "${{ secrets.DATA_SQL }}" > src/test/resources/test-data.sql

# Gradlew 실행 권한 허용
- name: Grant Execute Permission for Gradlew
run: chmod +x ./gradlew
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/develop_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ jobs:
java-version: '17'
distribution: 'temurin'

# 테스트 환경에서 필요한 컨테이너 실행 (redis, postgres)
- name: Run Containers
run: docker compose -f ./docker-compose-test.yml up -d

# 테스트 환경에서 필요한 스키마, 데이터 등록
- name: Apply Schema and Data
run: |
echo "${{ secrets.SCHEMA_SQL }}" > src/test/resources/test-schema.sql
echo "${{ secrets.DATA_SQL }}" > src/test/resources/test-data.sql

# Gradlew 실행 권한 허용
- name: Grant Execute Permission for Gradlew
run: chmod +x ./gradlew
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ out/
.vscode/

### env ###
.env
.env

### sql ###
*.sql
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-mail'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'org.postgresql:postgresql'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.9.3'


// Validation
implementation 'org.springframework.boot:spring-boot-starter-validation'

Expand Down
14 changes: 14 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
redis:
image: "redis:alpine"
ports:
- "6379:6379"

postgres:
image: "postgres:alpine"
ports:
- "5432:5432"
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: "ftm_test_db" # DB 자동 생성
2 changes: 1 addition & 1 deletion src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</appender>

<!-- 테스트 환경 -->
<springProfile name="local">
<springProfile name="test">
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/ftm/server/ServerApplicationTests.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.ftm.server;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;

@SpringBootTest
@ActiveProfiles("test")
@TestPropertySource(locations = "file:.env")
@AutoConfigureTestDatabase(
replace = AutoConfigureTestDatabase.Replace.NONE) // 테스트 시 내장된 인메모리 DB를 사용하지 않는다는 설정
class ServerApplicationTests {

@Test
Expand Down
16 changes: 13 additions & 3 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ spring:
on-profile: "test"

datasource:
url: jdbc:h2:mem:testDb;MODE=POSTGRESQL
url: jdbc:postgresql://localhost:5432/ftm_test_db
username: test
password: test
driver-class-name: org.postgresql.Driver

jpa:
database-platform: org.hibernate.dialect.H2Dialect
database-platform: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: none
show-sql: true
properties :
hibernate:
format_sql: true
default_batch_fetch_size: 1000
default_batch_fetch_size: 1000

sql:
init:
mode: always
schema-locations: classpath:test-schema.sql
data-locations: classpath:test-data.sql