You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/13 04:55:39 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #17504: Add unit test SingleTableSQLRouter#decorateRouteContext

strongduanmu commented on code in PR #17504:
URL: https://github.com/apache/shardingsphere/pull/17504#discussion_r871999753


##########
shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/SingleTableSQLRouterTest.java:
##########
@@ -104,6 +104,24 @@ public void assertCreateRouteContextWithMultiDataSource() {
         assertFalse(actual.isFederated());
     }
     
+    @Test
+    public void assertDecorateRouteContext() {
+        SingleTableRule singleTableRule = new SingleTableRule(new SingleTableRuleConfiguration(), DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class),
+                createSingleDataSourceMap(), Collections.emptyList(), new ConfigurationProperties(new Properties()));
+        singleTableRule.getSingleTableDataNodes().put("t_order", Collections.singletonList(mockDataNode("ds_0")));
+        ShardingSphereMetaData metaData = mockSingleDataSourceMetaData();
+        RouteContext actual = new RouteContext();

Review Comment:
   Hi @hoorf, please check the `decorateRouteContext` pre-logic, the `decorateRouteContext` method will be executed only when the RouteContext contains `rountUnits`. Also, since there are multiple implementations of SQLRouter, consider testing in multiple combined scenarios.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org