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
658562d7
Commit
658562d7
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-fix-wrong-parent-name' into dev
Moved code into different file though.
parents
4ad86b5d
ad22160a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#12842
passed
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/caosdb_test_utility.h
+10
-12
10 additions, 12 deletions
test/caosdb_test_utility.h
test/test_issues.cpp
+52
-0
52 additions, 0 deletions
test/test_issues.cpp
with
62 additions
and
12 deletions
test/caosdb_test_utility.h
+
10
−
12
View file @
658562d7
...
...
@@ -32,17 +32,15 @@
* @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)
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)
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_issues.cpp
+
52
−
0
View file @
658562d7
...
...
@@ -24,6 +24,7 @@ namespace fs = boost::filesystem;
namespace
caosdb
::
transaction
{
using
caosdb
::
entity
::
AtomicDataType
;
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
Parent
;
using
caosdb
::
entity
::
Role
;
using
caosdb
::
entity
::
Value
;
...
...
@@ -144,4 +145,55 @@ TEST_F(test_issues, server_issue_170) {
"update_status.IsError"
);
}
/*
* Insert a Record with a parent, which has a wrong name.
*
* This must result in a server error.
*/
TEST_F
(
test_issues
,
server_issue_171
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
// insert RT
Entity
rt
;
rt
.
SetRole
(
Role
::
RECORD_TYPE
);
rt
.
SetName
(
"Test_RT_Name"
);
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
=
insert_transaction
->
GetResultSet
();
const
auto
&
inserted_rt
=
insert_result_set
.
at
(
0
);
// create Record with parent
Entity
rec
;
rec
.
SetRole
(
Role
::
RECORD
);
rec
.
SetName
(
"TestRec"
);
Parent
parent
;
parent
.
SetId
(
inserted_rt
.
GetId
());
parent
.
SetName
(
rt
.
GetName
()
+
"_wrong"
);
rec
.
AppendParent
(
parent
);
// insert Record
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
());
EXPECT_NONFATAL_FAILURE
({
EXPECT_TRUE
(
rec_insert_status
.
IsError
());
},
"rec_insert_status.IsError"
);
const
auto
&
rec_result_set
=
rec_transaction
->
GetResultSet
();
const
auto
&
inserted_rec
=
rec_result_set
.
at
(
0
);
std
::
cout
<<
inserted_rec
.
ToString
()
<<
std
::
endl
;
}
}
// namespace caosdb::transaction
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