Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[고도화] 민감 정보의 환경변수 치환 후 테스트 실패 현상 수정 #89

Merged
merged 1 commit into from
Jan 24, 2023
Merged
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
#87 - 메인 스프링 부트 테스트에서 발생하는 에러 해결
DB 접근 정보가 환경변수 문법으로 치환되었는데
`@SpringBootTest`가 이를 그대로 읽으면서
올바른 jdbc url 포맷이 아니므로 실패를 유발함

이에 적당히 인메모리 테스트 db인 h2 경로를
새로 만든 테스트 전용 `test` 프로파일에 지정해주고,
테스트 실행 시 이 프로파일을 바라보게 하여
문제 해결
lmw7414 committed Jan 24, 2023
commit dd12d6f438f7a9a681aa23619995a7d5ef134953
11 changes: 10 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -53,4 +53,13 @@ spring:
datasource:
url: ${JAWSDB_URL}
jpa.hibernate.ddl-auto: create
sql.init.mode: always
sql.init.mode: always

---

spring:
config:
activate:
on-profile: test
datasource:
url: jdbc:h2:mem:testdb
Original file line number Diff line number Diff line change
@@ -2,7 +2,9 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
@SpringBootTest
class FastCampusProjectBoardApplicationTests {