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

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 84b0d58ced6 [Test](nereids) add ut for ShowTableCommand (#54053)
84b0d58ced6 is described below

commit 84b0d58ced66dc1c9c8d1850c3972a2d8fb58d27
Author: Jensen <[email protected]>
AuthorDate: Wed Jul 30 14:48:02 2025 +0800

    [Test](nereids) add ut for ShowTableCommand (#54053)
---
 .../trees/plans/commands/ShowTableCommandTest.java | 86 ++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTableCommandTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTableCommandTest.java
new file mode 100644
index 00000000000..03bcffa2768
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTableCommandTest.java
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.backup.CatalogMocker;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.datasource.InternalCatalog;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.qe.ConnectContext;
+
+import mockit.Expectations;
+import mockit.Mocked;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class ShowTableCommandTest {
+    @Mocked
+    private ConnectContext ctx;
+
+    @Test
+    public void testValidate() throws Exception {
+        new Expectations() {
+            {
+                ctx.getDatabase();
+                minTimes = 0;
+                result = CatalogMocker.TEST_DB_NAME;
+
+                ctx.getDefaultCatalog();
+                minTimes = 0;
+                result = InternalCatalog.INTERNAL_CATALOG_NAME;
+
+                ConnectContext.get();
+                minTimes = 0;
+                result = ctx;
+            }
+        };
+
+        ShowTableCommand command = new 
ShowTableCommand(CatalogMocker.TEST_DB_NAME,
+                InternalCatalog.INTERNAL_CATALOG_NAME, false, 
PlanType.SHOW_TABLES);
+        Assertions.assertDoesNotThrow(() -> command.validate(ctx));
+    }
+
+    @Test
+    void testInvalidate() {
+        new Expectations() {
+            {
+                ctx.getDatabase();
+                minTimes = 0;
+                result = "";
+
+                ctx.getDefaultCatalog();
+                minTimes = 0;
+                result = "";
+
+                ConnectContext.get();
+                minTimes = 0;
+                result = ctx;
+            }
+        };
+
+        // db is empty
+        ShowTableCommand command = new ShowTableCommand("",
+                InternalCatalog.INTERNAL_CATALOG_NAME, false, 
PlanType.SHOW_TABLES);
+        Assertions.assertThrows(AnalysisException.class, () -> 
command.validate(ctx));
+
+        // catalog is empty
+        ShowTableCommand command2 = new 
ShowTableCommand(CatalogMocker.TEST_DB_NAME,
+                "", false, PlanType.SHOW_TABLES);
+        Assertions.assertThrows(AnalysisException.class, () -> 
command2.validate(ctx));
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to