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
9592c098
Commit
9592c098
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Test insertion with parent
parent
5b88869e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
TST: Add Tests for insert and delete
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+59
-7
59 additions, 7 deletions
test/test_transaction.cpp
with
59 additions
and
7 deletions
test/test_transaction.cpp
+
59
−
7
View file @
9592c098
...
@@ -139,25 +139,77 @@ TEST(test_transaction, insert_delete) {
...
@@ -139,25 +139,77 @@ TEST(test_transaction, insert_delete) {
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
EXPECT_FALSE
(
deleted_entity
.
HasErrors
());
}
}
// TODO(fspreck) Insert an RT and a Record of this type, check
// TODO(fspreck) Simplify inserts and deletes once we have
// whether this is reflected correctly in the inserted Record, then
// multi-entity operations
// delete everything.
TEST
(
test_transaction
,
insert_delete_with_parent
)
{
TEST
(
test_transaction
,
insert_delete_with_parent
)
{
const
auto
&
connection
=
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
auto
insert_transaction
(
connection
->
CreateTransaction
());
Entity
entity
;
Entity
rt
;
entity
.
SetRole
(
"RecordType"
);
rt
.
SetRole
(
"RecordType"
);
entity
.
SetName
(
"RT
1
"
);
rt
.
SetName
(
"
Test
RT"
);
insert_transaction
->
InsertEntity
(
&
entity
);
insert_transaction
->
InsertEntity
(
&
rt
);
insert_transaction
->
ExecuteAsynchronously
();
insert_transaction
->
ExecuteAsynchronously
();
auto
insert_status
=
insert_transaction
->
WaitForIt
();
auto
insert_status
=
insert_transaction
->
WaitForIt
();
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_TRUE
(
insert_status
.
IsTerminated
());
ASSERT_FALSE
(
insert_status
.
IsError
());
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
());
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_EQ
(
inserted_rec
.
GetName
(),
rec
.
GetName
());
EXPECT_EQ
(
inserted_rec
.
GetParents
().
Size
(),
1
);
EXPECT_EQ
(
inserted_rec
.
GetParents
().
At
(
0
).
GetId
(),
inserted_rt
.
GetId
());
EXPECT_EQ
(
inserted_rec
.
GetParents
().
At
(
0
).
GetName
(),
inserted_rt
.
GetName
());
auto
rec_deletion
(
connection
->
CreateTransaction
());
rec_deletion
->
DeleteById
(
inserted_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
// TODO(fspreck) Insert a Record with a parent and a Property. Check
...
...
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