Skip to content
Snippets Groups Projects
test_transaction.cpp 2.18 KiB
Newer Older
/*
 * 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 <gtest/gtest-message.h>   // for Message
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl
#include <memory>                  // for allocator, make_shared, static_po...
#include <string>                  // for stoi
#include "caosdb/authentication.h" // for PlainPasswordAuthenticator
#include "caosdb/connection.h"     // for InsecureCaosDBConnectionConfig
#include "caosdb/entity.h"         // for Entity, EntityID
#include "caosdb/transaction.h"    // for Transaction, UniqueResult, Entity
#include "caosdb/utils.h"          // for get_env_var
#include "gtest/gtest_pred_impl.h" // for Test, TestInfo, EXPECT_EQ, TEST
#include "test_connection.h"

namespace caosdb::transaction {
using caosdb::authentication::PlainPasswordAuthenticator;
using caosdb::connection::CaosDBConnection;
using caosdb::connection::SslCaosDBConnectionConfig;

TEST(test_transaction, first_test) {
  auto connection = caosdb::connection::get_test_connection();
  auto description = "This is an entity";
  auto transaction(connection->CreateTransaction());
  transaction->Retrieve(caosdb::entity::EntityID("someid"));
  transaction->Execute();
  auto result_set(std::static_pointer_cast<caosdb::transaction::UniqueResult>(
    transaction->GetResultSet()));

  EXPECT_EQ(description, result_set->GetEntity().GetDescription());
}

} // namespace caosdb::transaction