-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5/12: migrate upload file to cloudinary
- Loading branch information
thuan
committed
Dec 5, 2023
1 parent
e50d262
commit c97df69
Showing
3 changed files
with
66 additions
and
61 deletions.
There are no files selected for viewing
114 changes: 57 additions & 57 deletions
114
src/test/java/com/spotify/app/AbstractTestcontainers.java
This file contains 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 |
---|---|---|
@@ -1,59 +1,59 @@ | ||
package com.spotify.app; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.flywaydb.core.Flyway; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.springframework.test.context.DynamicPropertySource; | ||
import org.testcontainers.containers.MySQLContainer; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
|
||
@Testcontainers | ||
@Slf4j | ||
public abstract class AbstractTestcontainers { | ||
|
||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
Flyway flyway = Flyway | ||
.configure() | ||
.dataSource( | ||
mySQLContainer.getJdbcUrl(), | ||
mySQLContainer.getUsername(), | ||
mySQLContainer.getPassword() | ||
).load(); | ||
flyway.migrate(); | ||
} | ||
@Container | ||
protected static final MySQLContainer<?> mySQLContainer = | ||
new MySQLContainer<>("mysql:latest") | ||
.withDatabaseName("spotify-dao-unit-test") | ||
.withUsername("kai") | ||
.withPassword("password") | ||
; | ||
|
||
@DynamicPropertySource | ||
static void dynamicProperties(DynamicPropertyRegistry registry) { | ||
registry.add("spring.datasource.url", mySQLContainer::getJdbcUrl); | ||
registry.add("spring.datasource.username", mySQLContainer::getUsername); | ||
registry.add("spring.datasource.password", mySQLContainer::getPassword); | ||
} | ||
|
||
//package com.spotify.app; | ||
// | ||
//import lombok.extern.slf4j.Slf4j; | ||
//import org.flywaydb.core.Flyway; | ||
//import org.junit.jupiter.api.BeforeAll; | ||
//import org.junit.jupiter.api.Test; | ||
//import org.springframework.test.context.DynamicPropertyRegistry; | ||
//import org.springframework.test.context.DynamicPropertySource; | ||
//import org.testcontainers.containers.MySQLContainer; | ||
//import org.testcontainers.junit.jupiter.Container; | ||
//import org.testcontainers.junit.jupiter.Testcontainers; | ||
//import org.testcontainers.utility.MountableFile; | ||
// | ||
//import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
// | ||
// | ||
//@Testcontainers | ||
//@Slf4j | ||
//public abstract class AbstractTestcontainers { | ||
// | ||
// | ||
// @BeforeAll | ||
// static void setUp() { | ||
// mySQLContainer.withInitScript("schema.sql"); | ||
// mySQLContainer.start(); | ||
// static void beforeAll() { | ||
// Flyway flyway = Flyway | ||
// .configure() | ||
// .dataSource( | ||
// mySQLContainer.getJdbcUrl(), | ||
// mySQLContainer.getUsername(), | ||
// mySQLContainer.getPassword() | ||
// ).load(); | ||
// flyway.migrate(); | ||
// } | ||
|
||
@Test | ||
void connectionEstablished() { | ||
assertThat(mySQLContainer.isCreated()).isTrue(); | ||
assertThat(mySQLContainer.isRunning()).isTrue(); | ||
} | ||
} | ||
// @Container | ||
// protected static final MySQLContainer<?> mySQLContainer = | ||
// new MySQLContainer<>("mysql:latest") | ||
// .withDatabaseName("spotify-dao-unit-test") | ||
// .withUsername("kai") | ||
// .withPassword("password") | ||
// ; | ||
// | ||
// @DynamicPropertySource | ||
// static void dynamicProperties(DynamicPropertyRegistry registry) { | ||
// registry.add("spring.datasource.url", mySQLContainer::getJdbcUrl); | ||
// registry.add("spring.datasource.username", mySQLContainer::getUsername); | ||
// registry.add("spring.datasource.password", mySQLContainer::getPassword); | ||
// } | ||
// | ||
//// @BeforeAll | ||
//// static void setUp() { | ||
//// mySQLContainer.withInitScript("schema.sql"); | ||
//// mySQLContainer.start(); | ||
//// } | ||
// | ||
// @Test | ||
// void connectionEstablished() { | ||
// assertThat(mySQLContainer.isCreated()).isTrue(); | ||
// assertThat(mySQLContainer.isRunning()).isTrue(); | ||
// } | ||
//} |
This file contains 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
This file contains 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