You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/04/01 15:08:52 UTC
[shardingsphere] branch master updated: SchemaRulePersistService#isExisted need add unit test (#16524)
This is an automated email from the ASF dual-hosted git repository.
yx9o pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 347b4b9 SchemaRulePersistService#isExisted need add unit test (#16524)
347b4b9 is described below
commit 347b4b9bafcc327c0505c3a1e7257cd9cdc4bd33
Author: 龙台 Long Tai <77...@users.noreply.github.com>
AuthorDate: Fri Apr 1 23:07:17 2022 +0800
SchemaRulePersistService#isExisted need add unit test (#16524)
* SchemaRulePersistService#isExisted need add unit test (16286)
* Optimize SchemaRulePersistServiceTest#assertisexisted unit test
---
.../persist/service/impl/SchemaRulePersistServiceTest.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/SchemaRulePersistServiceTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/SchemaRulePersistServiceTest.java
index fe40818..af6916d 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/SchemaRulePersistServiceTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/impl/SchemaRulePersistServiceTest.java
@@ -33,6 +33,7 @@ import java.util.Collection;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@@ -56,6 +57,15 @@ public final class SchemaRulePersistServiceTest {
assertThat(actual.size(), is(1));
}
+ @Test
+ public void assertIsExisted() {
+ when(repository.get("/metadata/foo_db/foo_db/active_version")).thenReturn("0");
+ when(repository.get("/metadata/foo_db/foo_db/versions/0/rules")).thenReturn(readYAML());
+ SchemaRulePersistService schemaRulePersistService = new SchemaRulePersistService(repository);
+ assertTrue(schemaRulePersistService.isExisted("foo_db"));
+ assertFalse(schemaRulePersistService.isExisted("foo_db_1"));
+ }
+
@SneakyThrows({IOException.class, URISyntaxException.class})
private String readYAML() {
return Files.readAllLines(Paths.get(ClassLoader.getSystemResource("yaml/persist/data-schema-rule.yaml").toURI()))