Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cppinttest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cppinttest
Commits
20f979b4
Verified
Commit
20f979b4
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: retrieve single entity
parent
49903b45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Pipeline
#9990
failed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
test/CMakeLists.txt
+2
-1
2 additions, 1 deletion
test/CMakeLists.txt
test/caosdb_test_utility.h
+48
-0
48 additions, 0 deletions
test/caosdb_test_utility.h
test/test_connection.cpp
+5
-5
5 additions, 5 deletions
test/test_connection.cpp
test/test_transaction.cpp
+56
-0
56 additions, 0 deletions
test/test_transaction.cpp
with
111 additions
and
6 deletions
test/CMakeLists.txt
+
2
−
1
View file @
20f979b4
...
...
@@ -76,7 +76,8 @@ foreach (i RANGE "${len_test_cases}")
${
CONAN_LIBS_GTEST
}
${
CONAN_LIBS_GRPC
}
${
CONAN_LIBS_ABSEIL
}
${
CONAN_LIBS_OPENSSL
}
${
CONAN_LIBS_C-ARES
}
${
CONAN_LIBS_BZIP2
}
${
CONAN_LIBS_PROTOBUF
}
${
CONAN_LIBS_ZLIB
}
${
CONAN_LIBS_RE2
}
)
target_include_directories
(
${
test_case_name
}
PUBLIC
${
CONAN_INCLUDE_DIRS
}
)
target_include_directories
(
${
test_case_name
}
PUBLIC
${
CONAN_INCLUDE_DIRS
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
set_target_properties
(
${
test_case_name
}
PROPERTIES
CXX_CLANG_TIDY
"
${
_CMAKE_CXX_CLANG_TIDY
}
;
${
_CMAKE_CXX_CLANG_TIDY_CHECKS
}
"
...
...
This diff is collapsed.
Click to expand it.
test/caosdb_test_utility.h
0 → 100644
+
48
−
0
View file @
20f979b4
/*
*
* 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/>.
*
*/
#ifndef CAOSDB_TEST_UTILITY_H
#define CAOSDB_TEST_UTILITY_H
/**
* WARNING: THIS FILE IS MAINTAINED AS PART OF THE caosdb-cpplib. Please commit
* changes there and keep these files in sync!
*
* @file caosdb_test_utility.h
* @brief Utility for the unit tests
* @author Timm Fitschen
* @date 2021-07-07
*/
#define EXPECT_THROW_MESSAGE(statement, exeption_type, message) EXPECT_THROW( \
try { \
statement; \
} catch (const exeption_type& e) { \
EXPECT_EQ(std::string(e.what()), message); \
throw; \
}, exeption_type)
#define ASSERT_THROW_MESSAGE(statement, exeption_type, message) ASSERT_THROW( \
try { \
statement; \
} catch (const exeption_type& e) { \
ASSERT_EQ(std::string(e.what()), message); \
throw; \
}, exeption_type)
#endif
This diff is collapsed.
Click to expand it.
test/test_connection.cpp
+
5
−
5
View file @
20f979b4
...
...
@@ -50,7 +50,7 @@ TEST(test_connection, connect_somehost_42347_fails) {
auto
config
=
std
::
make_shared
<
InsecureCaosDBConnectionConfig
>
(
pHost
,
port
);
CaosDBConnection
connection
(
config
);
EXPECT_THROW
(
connection
.
g
etVersionInfo
(),
ConnectionError
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
ConnectionError
);
}
TEST
(
test_connection
,
connection_insecure_authentication_error_wrong_credentials
)
{
...
...
@@ -65,7 +65,7 @@ TEST(test_connection, connection_insecure_authentication_error_wrong_credentials
auto
config
=
std
::
make_shared
<
InsecureCaosDBConnectionConfig
>
(
host
,
port
,
auth
);
auto
connection
=
CaosDBConnection
(
config
);
EXPECT_THROW
(
connection
.
g
etVersionInfo
(),
AuthenticationError
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
AuthenticationError
);
}
...
...
@@ -77,7 +77,7 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
auto
config
=
std
::
make_shared
<
InsecureCaosDBConnectionConfig
>
(
host
,
port
);
auto
connection
=
CaosDBConnection
(
config
);
EXPECT_THROW
(
connection
.
g
etVersionInfo
(),
AuthenticationError
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
AuthenticationError
);
}
TEST
(
test_connection
,
connection_ssl_authentication_error_anonymous
)
{
...
...
@@ -90,7 +90,7 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
auto
config
=
std
::
make_shared
<
SslCaosDBConnectionConfig
>
(
host
,
port
,
ssloptions
);
auto
connection
=
CaosDBConnection
(
config
);
EXPECT_THROW
(
connection
.
g
etVersionInfo
(),
AuthenticationError
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
AuthenticationError
);
}
TEST
(
test_connection
,
connection_ssl_authentication_error_wrong_credentials
)
{
...
...
@@ -106,7 +106,7 @@ TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
auto
config
=
std
::
make_shared
<
SslCaosDBConnectionConfig
>
(
host
,
port
,
ssloptions
,
auth
);
auto
connection
=
CaosDBConnection
(
config
);
EXPECT_THROW
(
connection
.
g
etVersionInfo
(),
AuthenticationError
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
AuthenticationError
);
}
TEST
(
test_connection
,
connection_ssl_authentication_success
)
{
...
...
This diff is collapsed.
Click to expand it.
test/test_transaction.cpp
0 → 100644
+
56
−
0
View file @
20f979b4
/*
* 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/transaction.h"
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestPartResult
#include
<memory>
// for make_shared, allocator, shared_ptr
#include
<string>
// for string
#include
"caosdb/authentication.h"
// for PlainPasswordAuthenticator
#include
"caosdb/connection.h"
// for InsecureCaosDBConnectionConfig
#include
"caosdb/exceptions.h"
// for AuthenticationError, ConnectionError
#include
"caosdb/utils.h"
// for get_env_var
#include
"gtest/gtest_pred_impl.h"
// for Test, TEST, EXPECT_EQ, EXPECT_THROW
namespace
caosdb
::
transaction
{
TEST
(
test_transaction
,
first_test
)
{
auto
port_str
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_GRPC_PORT_HTTP"
,
"8080"
);
auto
port
=
std
::
stoi
(
port_str
);
const
auto
host
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_HOST"
,
"localhost"
);
const
auto
user
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_USER"
,
"admin"
);
const
auto
password
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_PASSWORD"
,
"caosdb"
);
const
auto
*
const
description
=
"This is an entity"
;
auto
auth
=
std
::
make_shared
<
PlainPasswordAuthenticator
>
(
user
,
password
);
auto
config
=
std
::
make_shared
<
SslCaosDBConnectionConfig
>
(
host
,
port
,
auth
);
auto
connection
=
CaosDBConnection
(
config
);
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::connection
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment