-
Notifications
You must be signed in to change notification settings - Fork 8
test: flyway 스크립트를 검증하는 테스트 코드 작성 #588
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
Merged
whqtker
merged 5 commits into
solid-connection:develop
from
whqtker:test/587-verify-flyway-script
Dec 29, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d8c1a9
test: flyway 스크립트를 검증하는 테스트 코드 작성
whqtker 97e8309
fix: DirtiesContext 어노테이션을 통해 기존 컨텍스트를 폐기하도록
whqtker 089076a
fix: flyway 검증용의 별도의 MySQL 컨테이너를 사용하도록
whqtker 7c03e92
chore: 테스트 의도를 쉽게 이해할 수 있도록 주석 추가
whqtker dfa9a9b
chore: 명시적으로 컨테이너를 시작하도록
whqtker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/test/java/com/example/solidconnection/database/FlywayMigrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.example.solidconnection.database; | ||
|
|
||
| import com.example.solidconnection.support.RedisTestContainer; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.boot.test.util.TestPropertyValues; | ||
| import org.springframework.context.ApplicationContextInitializer; | ||
| import org.springframework.context.ConfigurableApplicationContext; | ||
| import org.springframework.test.context.ContextConfiguration; | ||
| import org.springframework.test.context.TestPropertySource; | ||
| import org.testcontainers.containers.MySQLContainer; | ||
| import org.testcontainers.junit.jupiter.Container; | ||
| import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
|
||
| @SpringBootTest | ||
| @Testcontainers | ||
| @ContextConfiguration(initializers = {RedisTestContainer.class, FlywayMigrationTest.FlywayMySQLInitializer.class}) | ||
| @TestPropertySource(properties = { | ||
| "spring.flyway.enabled=true", | ||
| "spring.flyway.baseline-on-migrate=true", | ||
| "spring.jpa.hibernate.ddl-auto=validate" | ||
| }) | ||
| class FlywayMigrationTest { | ||
|
|
||
| @Container | ||
| private static final MySQLContainer<?> MYSQL = new MySQLContainer<>("mysql:8.0") | ||
| .withDatabaseName("flyway_test") | ||
| .withUsername("flyway_user") | ||
| .withPassword("flyway_password"); | ||
|
|
||
| static class FlywayMySQLInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | ||
| @Override | ||
| public void initialize(ConfigurableApplicationContext ctx) { | ||
| TestPropertyValues.of( | ||
| "spring.datasource.url=" + MYSQL.getJdbcUrl(), | ||
| "spring.datasource.username=" + MYSQL.getUsername(), | ||
| "spring.datasource.password=" + MYSQL.getPassword() | ||
| ).applyTo(ctx.getEnvironment()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void flyway_스크립트가_정상적으로_수행되는지_확인한다() { | ||
| // Spring Boot 컨텍스트가 정상적으로 시작되면 | ||
| // Flyway 마이그레이션과 ddl-auto=validate 검증이 성공한 것 | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.