From df154b88a5028b52dfe4cf289bdf03eddcbd2f81 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Tue, 3 Aug 2021 23:46:29 +0200 Subject: [PATCH] WIP: files --- conanfile.txt | 2 +- test/CMakeLists.txt | 1 + test/test_file_transmission.cpp | 58 +++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/test_file_transmission.cpp diff --git a/conanfile.txt b/conanfile.txt index 0cff1c9..a5a7c5f 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,5 +1,5 @@ [requires] -caosdb/0.0.9 +caosdb/0.0.10 gtest/1.11.0 [generators] diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 23ef7d4..4b04ecc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,6 +23,7 @@ ####################################################################### set(test_cases test_connection + test_file_transmission test_transaction test_ccaosdb ) diff --git a/test/test_file_transmission.cpp b/test/test_file_transmission.cpp new file mode 100644 index 0000000..a54fbc7 --- /dev/null +++ b/test/test_file_transmission.cpp @@ -0,0 +1,58 @@ +/* + * This file is a part of the CaosDB Project. + * + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@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/entity/v1alpha1/main.pb.h" +#include "caosdb/transaction.h" // for Entity, Transaction, UniqueRe... +#include "gtest/gtest-message.h" // for Message +#include "gtest/gtest-test-part.h" // for TestPartResult, SuiteApiResolver +#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, AssertionResult +#include <memory> // for unique_ptr, allocator, __shar... +#include <string> // for string +namespace caosdb::transaction { +using caosdb::entity::v1alpha1::RegisterFileUploadResponse; +using caosdb::entity::v1alpha1::RegistrationStatus; + +class test_file_transmission : public ::testing::Test { +protected: + void SetUp() override {} + + void TearDown() override { + // TODO(tf): delete all created entities + } +}; + +TEST_F(test_file_transmission, register_file_upload) { + const auto &connection = + caosdb::connection::ConnectionManager::GetDefaultConnection(); + + auto transaction(connection->CreateTransaction()); + RegisterFileUploadResponse response; + EXPECT_EQ(response.status(), + RegistrationStatus::REGISTRATION_STATUS_UNSPECIFIED); + + transaction->RegisterUploadFile(&response); + + EXPECT_EQ(response.status(), + RegistrationStatus::REGISTRATION_STATUS_ACCEPTED); + EXPECT_FALSE(response.registration_id().empty()); +} + +} // namespace caosdb::transaction -- GitLab