From ef5b60b0921bec6c088964822eceb6a478e51f4e Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 21 Oct 2022 00:30:39 +0200
Subject: [PATCH] WIP: SELECT for GRPC API

---
 test/CMakeLists.txt  |  1 +
 test/test_select.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 test/test_select.cpp

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0053aaa..4c74001 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -30,6 +30,7 @@ set(test_cases
     test_ccaosdb
     test_issues
     test_user
+    test_select
     )
 
 add_compile_definitions(BUILD_ACM)
diff --git a/test/test_select.cpp b/test/test_select.cpp
new file mode 100644
index 0000000..9d4024b
--- /dev/null
+++ b/test/test_select.cpp
@@ -0,0 +1,47 @@
+/*
+ * This file is a part of the CaosDB Project.
+ *
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
+ * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
+ * Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+#include "caosdb/connection.h"      // for Connection, ConnectionManager
+#include "caosdb/transaction.h"     // for Transaction, ResultTable
+#include <gtest/gtest-message.h>    // for Message
+#include <gtest/gtest-test-part.h>  // for SuiteApiResolver, TestFactoryImpl
+#include <gtest/gtest_pred_impl.h>  // for Test, TestInfo, EXPECT_EQ, TEST
+#include <memory>                   // for allocator, unique_ptr, __shared_p...
+                                    //
+namespace caosdb::transaction {
+
+/*
+ * Test select query on empty database.
+ */
+TEST(test_transaction, test_select) {
+  const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
+
+  auto query_transaction(connection->CreateTransaction());
+  query_transaction->Query("SELECT name FROM ENTITY WITH id > 99");
+  query_transaction->Execute();
+  EXPECT_EQ(query_transaction->GetResultTable().size(), 0);
+  EXPECT_EQ(query_transaction->GetResultTable().GetHeader().size(), 1);
+  for(const auto &column : query_transaction->GetResultTable().GetHeader()) {
+    EXPECT_EQ(column.GetName(), "name");
+  }
+}
+
+} // namespace caosdb::transaction
-- 
GitLab