You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/16 14:28:20 UTC

[shardingsphere] branch master updated: Add unit test for ModShardingAlgorithm (#17710)

This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 cd7c950918a Add unit test for ModShardingAlgorithm  (#17710)
cd7c950918a is described below

commit cd7c950918ae213f34715f3aee11a320cc44760c
Author: galaxy <ga...@tencent.com>
AuthorDate: Mon May 16 22:28:14 2022 +0800

    Add unit test for ModShardingAlgorithm  (#17710)
    
    * Add unit test for ModShardingAlgorithm (#17605)
---
 .../sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
index 065b10018f8..80cffac5de4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
@@ -91,6 +91,14 @@ public final class ModShardingAlgorithmTest {
         assertThat(actual.size(), is(16));
     }
     
+    @Test(expected = IllegalArgumentException.class)
+    public void assertRangeDoShardingWithWrongArgument() {
+        Properties properties = createZeroPaddingProperties();
+        properties.setProperty("start-offset", "-1");
+        ModShardingAlgorithm algorithm = (ModShardingAlgorithm) ShardingAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("MOD", properties));
+        assertThat(algorithm.doSharding(createAvailableIncludeZeroTargetNames(), new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, "12345678910111213141516")), is("t_order_07"));
+    }
+    
     private Properties createZeroPaddingProperties() {
         Properties result = new Properties();
         result.setProperty("sharding-count", "16");