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
e26e95a0
Verified
Commit
e26e95a0
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-multi-retrieve' into f-update
parents
caaf5f2d
37f38368
No related branches found
No related tags found
1 merge request
!5
F update
Pipeline
#11226
failed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test_connection.cpp
+5
-2
5 additions, 2 deletions
test/test_connection.cpp
test/test_transaction.cpp
+100
-6
100 additions, 6 deletions
test/test_transaction.cpp
with
105 additions
and
8 deletions
test/test_connection.cpp
+
5
−
2
View file @
e26e95a0
...
@@ -73,7 +73,8 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
...
@@ -73,7 +73,8 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
EXPECT_THROW
(
connection
.
RetrieveVersionInfo
(),
AuthenticationError
);
EXPECT_THROW
(
connection
.
RetrieveVersionInfo
(),
AuthenticationError
);
}
}
TEST
(
test_connection
,
connection_ssl_authentication_error_anonymous
)
{
// TODO(tf) cognitive complexity > 25 (threshold)
TEST
(
test_connection
,
connection_ssl_authentication_error_anonymous
)
{
// NOLINT
const
auto
*
port_str
=
const
auto
*
port_str
=
caosdb
::
utility
::
get_env_var
(
"CAOSDB_SERVER_GRPC_PORT_HTTPS"
,
"8443"
);
caosdb
::
utility
::
get_env_var
(
"CAOSDB_SERVER_GRPC_PORT_HTTPS"
,
"8443"
);
auto
port
=
std
::
stoi
(
port_str
);
auto
port
=
std
::
stoi
(
port_str
);
...
@@ -92,7 +93,9 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
...
@@ -92,7 +93,9 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
"succeed. Original error: Please login."
);
"succeed. Original error: Please login."
);
}
}
TEST
(
test_connection
,
connection_ssl_authentication_error_wrong_credentials
)
{
// TODO(tf) cognitive complexity > 25 (threshold)
TEST
(
test_connection
,
// NOLINT
connection_ssl_authentication_error_wrong_credentials
)
{
// NOLINT
const
auto
*
port_str
=
const
auto
*
port_str
=
caosdb
::
utility
::
get_env_var
(
"CAOSDB_SERVER_GRPC_PORT_HTTPS"
,
"8443"
);
caosdb
::
utility
::
get_env_var
(
"CAOSDB_SERVER_GRPC_PORT_HTTPS"
,
"8443"
);
auto
port
=
std
::
stoi
(
port_str
);
auto
port
=
std
::
stoi
(
port_str
);
...
...
This diff is collapsed.
Click to expand it.
test/test_transaction.cpp
+
100
−
6
View file @
e26e95a0
...
@@ -27,14 +27,14 @@
...
@@ -27,14 +27,14 @@
#include
"gtest/gtest-message.h"
// for Message
#include
"gtest/gtest-message.h"
// for Message
#include
"gtest/gtest-test-part.h"
// for TestPartResult, SuiteApiResolver
#include
"gtest/gtest-test-part.h"
// for TestPartResult, SuiteApiResolver
#include
"gtest/gtest_pred_impl.h"
// for Test, EXPECT_EQ, AssertionResult
#include
"gtest/gtest_pred_impl.h"
// for Test, EXPECT_EQ, AssertionResult
#include
<iostream>
#include
<iostream>
// for endl, basic_ostream, cout
#include
<memory>
// for unique_ptr, allocator, __shar...
#include
<memory>
// for unique_ptr, allocator, __shar...
#include
<string>
// for string
#include
<string>
// for string
#include
<vector>
// for vector
#include
<vector>
// for vector
namespace
caosdb
::
transaction
{
namespace
caosdb
::
transaction
{
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
MessageCode
;
using
caosdb
::
entity
::
MessageCode
;
using
caosdb
::
entity
::
Parent
;
class
test_transaction
:
public
::
testing
::
Test
{
class
test_transaction
:
public
::
testing
::
Test
{
protected:
protected:
...
@@ -95,7 +95,8 @@ TEST(test_transaction, retrieve_non_existing) {
...
@@ -95,7 +95,8 @@ TEST(test_transaction, retrieve_non_existing) {
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
}
}
TEST
(
test_transaction
,
insert_delete
)
{
// TODO(fspreck) cognitive complexity > 25 (threshold)
TEST
(
test_transaction
,
insert_delete
)
{
// NOLINT
const
auto
&
connection
=
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
...
@@ -142,6 +143,99 @@ TEST(test_transaction, insert_delete) {
...
@@ -142,6 +143,99 @@ TEST(test_transaction, insert_delete) {
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
}
}
// TODO(fspreck) Simplify inserts and deletes once we have
// multi-entity operations, also cognitive complexity > threshold
TEST
(
test_transaction
,
insert_delete_with_parent
)
{
// NOLINT
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
rt
;
rt
.
SetRole
(
"RecordType"
);
rt
.
SetName
(
"TestRT"
);
insert_transaction
->
InsertEntity
(
&
rt
);
insert_transaction
->
ExecuteAsynchronously
();
auto
insert_status
=
insert_transaction
->
WaitForIt
();
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_FALSE
(
insert_status
.
IsError
());
const
auto
&
insert_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
insert_transaction
->
GetResultSet
());
const
auto
&
inserted_rt
=
insert_result_set
.
GetEntity
();
Entity
rec
;
rec
.
SetRole
(
"Record"
);
rec
.
SetName
(
"TestRec"
);
Parent
parent
;
parent
.
SetName
(
rt
.
GetName
());
parent
.
SetId
(
inserted_rt
.
GetId
());
rec
.
AppendParent
(
parent
);
auto
rec_transaction
(
connection
->
CreateTransaction
());
rec_transaction
->
InsertEntity
(
&
rec
);
rec_transaction
->
ExecuteAsynchronously
();
auto
rec_insert_status
=
rec_transaction
->
WaitForIt
();
ASSERT_TRUE
(
rec_insert_status
.
IsTerminated
());
ASSERT_FALSE
(
rec_insert_status
.
IsError
());
const
auto
&
rec_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
rec_transaction
->
GetResultSet
());
const
auto
&
inserted_rec
=
rec_result_set
.
GetEntity
();
EXPECT_FALSE
(
inserted_rec
.
GetId
().
empty
());
auto
retrieve_transaction
(
connection
->
CreateTransaction
());
retrieve_transaction
->
RetrieveById
(
inserted_rec
.
GetId
());
retrieve_transaction
->
ExecuteAsynchronously
();
auto
rec_retrieve_status
=
retrieve_transaction
->
WaitForIt
();
ASSERT_TRUE
(
rec_retrieve_status
.
IsTerminated
());
ASSERT_FALSE
(
rec_retrieve_status
.
IsError
());
const
auto
&
retrieve_result_set
=
dynamic_cast
<
const
UniqueResult
&>
(
retrieve_transaction
->
GetResultSet
());
const
auto
&
retrieved_rec
=
retrieve_result_set
.
GetEntity
();
std
::
cout
<<
retrieved_rec
.
ToString
()
<<
std
::
endl
;
EXPECT_EQ
(
retrieved_rec
.
GetName
(),
rec
.
GetName
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
Size
(),
1
);
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
At
(
0
).
GetId
(),
inserted_rt
.
GetId
());
EXPECT_EQ
(
retrieved_rec
.
GetParents
().
At
(
0
).
GetName
(),
rt
.
GetName
());
auto
rec_deletion
(
connection
->
CreateTransaction
());
rec_deletion
->
DeleteById
(
retrieved_rec
.
GetId
());
rec_deletion
->
ExecuteAsynchronously
();
auto
rec_delete_status
=
rec_deletion
->
WaitForIt
();
ASSERT_TRUE
(
rec_delete_status
.
IsTerminated
());
ASSERT_FALSE
(
rec_delete_status
.
IsError
());
auto
rt_deletion
(
connection
->
CreateTransaction
());
rt_deletion
->
DeleteById
(
inserted_rt
.
GetId
());
rt_deletion
->
ExecuteAsynchronously
();
auto
rt_delete_status
=
rt_deletion
->
WaitForIt
();
ASSERT_TRUE
(
rt_delete_status
.
IsTerminated
());
ASSERT_FALSE
(
rt_delete_status
.
IsError
());
}
// TODO(fspreck) Insert a Record with a parent and a Property. Check
// for success and delete everything.
TEST
(
test_transaction
,
test_multi_retrieve
)
{
TEST
(
test_transaction
,
test_multi_retrieve
)
{
const
auto
&
connection
=
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
...
...
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