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
2a138f26
Commit
2a138f26
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
DOC: comments in test_transaction
parent
950e0848
No related branches found
No related tags found
1 merge request
!9
F consolidation
Pipeline
#12248
failed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+29
-11
29 additions, 11 deletions
test/test_transaction.cpp
with
29 additions
and
11 deletions
test/test_transaction.cpp
+
29
−
11
View file @
2a138f26
...
...
@@ -57,6 +57,7 @@ protected:
test_upload_file_1
=
fs
::
path
(
"test_upload_file_1_delete_me.dat"
);
test_download_file_1
=
fs
::
path
(
"test_download_file_1_delete_me.dat"
);
// fill the file that shall be uploaded
FileWriter
writer
(
test_upload_file_1
);
std
::
string
buffer
(
1024
,
'c'
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
...
...
@@ -65,11 +66,13 @@ protected:
}
void
TearDown
()
override
{
// delete files
fs
::
remove
(
test_upload_file_1
);
fs
::
remove
(
test_download_file_1
);
// delete all entities
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
query_transaction
(
connection
->
CreateTransaction
());
query_transaction
->
Query
(
"FIND ENTITY WITH id > 99"
);
query_transaction
->
Execute
();
...
...
@@ -83,9 +86,15 @@ protected:
}
};
/*
* Test the retrieval of a non-existing entity
*
* The transaction returns an error code and the entity has the appropriate
* error message
*/
TEST_F
(
test_transaction
,
retrieve_non_existing
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
transaction
(
connection
->
CreateTransaction
());
...
...
@@ -107,9 +116,15 @@ TEST_F(test_transaction, retrieve_non_existing) {
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
}
/*
* Testing the insertion of a basic entity
* Transaction should terminate without errors.
* Returned entity should have an id, no errors and a warning since no property
* is set.
*/
TEST_F
(
test_transaction
,
insert_without_delete
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
...
...
@@ -136,9 +151,15 @@ TEST_F(test_transaction, insert_without_delete) {
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
}
/*
* Test deletion of an entity
* Insert an entity first.
*/
TEST_F
(
test_transaction
,
insert_delete
)
{
// same as in insert_without_delete
// until marked END SAME
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
...
...
@@ -157,12 +178,7 @@ TEST_F(test_transaction, insert_delete) {
const
auto
&
new_entity
=
insert_result_set
.
at
(
0
);
EXPECT_FALSE
(
new_entity
.
GetId
().
empty
());
EXPECT_FALSE
(
new_entity
.
HasErrors
());
// Should have a warning since it has no properties
EXPECT_TRUE
(
new_entity
.
HasWarnings
());
EXPECT_EQ
(
new_entity
.
GetWarnings
().
size
(),
1
);
EXPECT_EQ
(
new_entity
.
GetWarnings
().
at
(
0
).
GetCode
(),
MessageCode
::
ENTITY_HAS_NO_PROPERTIES
);
// END SAME
auto
delete_transaction
(
connection
->
CreateTransaction
());
...
...
@@ -183,10 +199,11 @@ TEST_F(test_transaction, insert_delete) {
TEST_F
(
test_transaction
,
insert_delete_with_parent
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
// insert RT
Entity
rt
;
rt
.
SetRole
(
Role
::
RECORD_TYPE
);
rt
.
SetName
(
"TestRT"
);
...
...
@@ -202,6 +219,7 @@ TEST_F(test_transaction, insert_delete_with_parent) {
const
auto
&
inserted_rt
=
insert_result_set
.
at
(
0
);
// insert Record with parent
Entity
rec
;
rec
.
SetRole
(
Role
::
RECORD
);
rec
.
SetName
(
"TestRec"
);
...
...
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