暂存提交
This commit is contained in:
+17
-2
@@ -1,17 +1,32 @@
|
||||
package com.baiyue.warehouse.config;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class WarehouseDatabaseGuardConfigurationTest {
|
||||
@Test
|
||||
void applicationDefaultsTargetDedicatedOverseasWarehouseDatabase() throws Exception {
|
||||
var properties = new YamlPropertySourceLoader()
|
||||
.load("application", new ClassPathResource("application.yml"))
|
||||
.get(0);
|
||||
|
||||
assertThat(properties.getProperty("spring.datasource.url"))
|
||||
.asString()
|
||||
.contains("baiyue_lastlag_warehouse")
|
||||
.doesNotContain("baiyue_lastlag_warehouse");
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptsDedicatedOverseasWarehouseDatabase() {
|
||||
MockEnvironment environment = new MockEnvironment()
|
||||
.withProperty("spring.datasource.url",
|
||||
"jdbc:mysql://127.0.0.1:3306/baiyue_warehouse_overseas?serverTimezone=Asia/Shanghai");
|
||||
"jdbc:mysql://127.0.0.1:3306/baiyue_lastlag_warehouse?serverTimezone=Asia/Shanghai");
|
||||
|
||||
assertThatCode(() -> WarehouseDatabaseGuardConfiguration.warehouseDatabaseGuard(environment))
|
||||
.doesNotThrowAnyException();
|
||||
@@ -24,6 +39,6 @@ class WarehouseDatabaseGuardConfigurationTest {
|
||||
|
||||
assertThatThrownBy(() -> WarehouseDatabaseGuardConfiguration.warehouseDatabaseGuard(environment))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("baiyue_warehouse_overseas");
|
||||
.hasMessageContaining("baiyue_lastlag_warehouse");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user