-
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
Open
whqtker
wants to merge
3
commits into
solid-connection:develop
Choose a base branch
from
whqtker:test/587-verify-flyway-script
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
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,45 @@ | ||
| 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_스크립트가_정상적으로_수행되는지_확인한다() { | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Spring Boot 컨텍스트가 정상적으로 시작되면
// Flyway 마이그레이션과 ddl-auto=validate 검증이 성공한 것
이런느낌의 주석만 안에 하나 들어가는 거 어떤가요~?