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
b5994d0d
Commit
b5994d0d
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Adapt tests to consolidated C
parent
6d4ff087
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
ENH: Test insert/update/delete and files in Extern C
Pipeline
#12339
passed
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_ccaosdb.cpp
+65
-49
65 additions, 49 deletions
test/test_ccaosdb.cpp
with
65 additions
and
49 deletions
test/test_ccaosdb.cpp
+
65
−
49
View file @
b5994d0d
...
...
@@ -25,7 +25,8 @@
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, SuiteApiResolver
#include
<memory>
// for allocator, unique_ptr
#include
<iostream>
#include
<memory>
// for allocator, unique_ptr
class
test_ccaosdb
:
public
::
testing
::
Test
{
protected:
...
...
@@ -55,10 +56,10 @@ protected:
caosdb_connection_connection_create_transaction
(
&
connection
,
&
delete_transaction
);
caosdb_entity_entity
entity
;
char
id
[
255
]
=
{
"id"
}
;
// NOLINT
char
*
id
=
nullptr
;
// NOLINT
for
(
int
i
=
0
;
i
<
*
count
;
i
++
)
{
caosdb_transaction_result_set_at
(
&
result_set
,
&
entity
,
i
);
caosdb_entity_entity_get_id
(
&
entity
,
id
);
caosdb_entity_entity_get_id
(
&
entity
,
&
id
);
caosdb_transaction_transaction_delete_by_id
(
&
delete_transaction
,
id
);
}
...
...
@@ -269,8 +270,8 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
caosdb_entity_entity
original_entity
;
caosdb_entity_create_entity
(
&
original_entity
);
caosdb_entity_entity_set_name
(
&
original_entity
,
"TestName"
);
caosdb_entity_entity_set_role
(
&
original_entity
,
"P
roperty
"
);
caosdb_entity_entity_set_datatype
(
&
original_entity
,
"TEXT"
);
caosdb_entity_entity_set_role
(
&
original_entity
,
"P
ROPERTY
"
);
caosdb_entity_entity_set_datatype
(
&
original_entity
,
"TEXT"
,
false
,
false
);
caosdb_transaction_transaction
insert_transaction
;
caosdb_connection_connection_create_transaction
(
&
connection
,
...
...
@@ -289,8 +290,8 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
EXPECT_EQ
(
*
count
,
1
);
caosdb_entity_entity
inserted_entity
;
caosdb_transaction_result_set_at
(
&
insert_result_set
,
&
inserted_entity
,
0
);
char
in
[
255
]
=
{
"id"
}
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_entity
,
in
);
char
*
in
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_entity
,
&
in
);
// Retrieve it again for checks and update
caosdb_transaction_transaction
retrieve_transaction_1
;
...
...
@@ -307,21 +308,29 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
EXPECT_EQ
(
*
count
,
1
);
caosdb_entity_entity
retrieved_entity_1
;
caosdb_transaction_result_set_at
(
&
retrieve_results_1
,
&
retrieved_entity_1
,
0
);
char
out
[
255
]
=
{
"id"
}
;
// NOLINT
caosdb_entity_entity_get_id
(
&
retrieved_entity_1
,
out
);
char
*
out
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_id
(
&
retrieved_entity_1
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_entity_get_name
(
&
original_entity
,
in
);
caosdb_entity_entity_get_name
(
&
retrieved_entity_1
,
out
);
caosdb_entity_entity_get_name
(
&
original_entity
,
&
in
);
caosdb_entity_entity_get_name
(
&
retrieved_entity_1
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_entity_get_role
(
&
original_entity
,
in
);
caosdb_entity_entity_get_role
(
&
retrieved_entity_1
,
out
);
caosdb_entity_entity_get_role
(
&
original_entity
,
&
in
);
caosdb_entity_entity_get_role
(
&
retrieved_entity_1
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_entity_get_datatype
(
&
original_entity
,
in
);
caosdb_entity_entity_get_datatype
(
&
retrieved_entity_1
,
out
);
bool
is_list_in
[]
=
{
false
};
// NOLINT
bool
is_ref_in
[]
=
{
false
};
// NOLINT
caosdb_entity_entity_get_datatype
(
&
original_entity
,
&
in
,
is_ref_in
,
is_list_in
);
bool
is_list_out
[]
=
{
false
};
// NOLINT
bool
is_ref_out
[]
=
{
false
};
// NOLINT
caosdb_entity_entity_get_datatype
(
&
retrieved_entity_1
,
&
out
,
is_ref_out
,
is_list_out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
EXPECT_EQ
(
*
is_list_in
,
*
is_list_out
);
EXPECT_EQ
(
*
is_ref_in
,
*
is_ref_out
);
// Change name and update
return_code
=
...
...
@@ -342,8 +351,8 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
EXPECT_EQ
(
*
count
,
1
);
caosdb_entity_entity
updated_entity
;
caosdb_transaction_result_set_at
(
&
update_results
,
&
updated_entity
,
0
);
caosdb_entity_entity_get_id
(
&
inserted_entity
,
in
);
caosdb_entity_entity_get_id
(
&
updated_entity
,
out
);
caosdb_entity_entity_get_id
(
&
inserted_entity
,
&
in
);
caosdb_entity_entity_get_id
(
&
updated_entity
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
// Retrieve again
...
...
@@ -362,31 +371,35 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
caosdb_entity_entity
retrieved_entity_2
;
caosdb_transaction_result_set_at
(
&
retrieve_results_2
,
&
retrieved_entity_2
,
0
);
caosdb_entity_entity_get_id
(
&
retrieved_entity_2
,
out
);
caosdb_entity_entity_get_id
(
&
retrieved_entity_2
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_entity_get_name
(
&
retrieved_entity_1
,
in
);
caosdb_entity_entity_get_name
(
&
retrieved_entity_2
,
out
);
caosdb_entity_entity_get_name
(
&
retrieved_entity_1
,
&
in
);
caosdb_entity_entity_get_name
(
&
retrieved_entity_2
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
// Doesn't have the old name anymore
caosdb_entity_entity_get_name
(
&
original_entity
,
in
);
caosdb_entity_entity_get_name
(
&
original_entity
,
&
in
);
EXPECT_FALSE
((
strcmp
(
in
,
out
)
==
0
));
// Everything else hasn't changed
caosdb_entity_entity_get_role
(
&
original_entity
,
in
);
caosdb_entity_entity_get_role
(
&
retrieved_entity_2
,
out
);
caosdb_entity_entity_get_role
(
&
original_entity
,
&
in
);
caosdb_entity_entity_get_role
(
&
retrieved_entity_2
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_entity_get_datatype
(
&
original_entity
,
in
);
caosdb_entity_entity_get_datatype
(
&
retrieved_entity_2
,
out
);
caosdb_entity_entity_get_datatype
(
&
original_entity
,
&
in
,
is_ref_in
,
is_list_in
);
caosdb_entity_entity_get_datatype
(
&
retrieved_entity_2
,
&
out
,
is_ref_out
,
is_list_out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
EXPECT_EQ
(
*
is_ref_in
,
*
is_ref_out
);
EXPECT_EQ
(
*
is_list_in
,
*
is_list_out
);
// Now delete
caosdb_transaction_transaction
delete_transaction
;
caosdb_connection_connection_create_transaction
(
&
connection
,
&
delete_transaction
);
caosdb_entity_entity_get_id
(
&
retrieved_entity_2
,
in
);
caosdb_entity_entity_get_id
(
&
retrieved_entity_2
,
&
in
);
caosdb_transaction_transaction_delete_by_id
(
&
delete_transaction
,
in
);
return_code
=
caosdb_transaction_transaction_execute
(
&
delete_transaction
);
EXPECT_EQ
(
return_code
,
0
);
...
...
@@ -399,7 +412,7 @@ TEST_F(test_ccaosdb, test_insert_update_delete) {
caosdb_entity_entity
deleted_entity
;
caosdb_transaction_result_set_at
(
&
delete_results
,
&
deleted_entity
,
0
);
caosdb_entity_entity_get_id
(
&
deleted_entity
,
out
);
caosdb_entity_entity_get_id
(
&
deleted_entity
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
// Try to retrieve again
...
...
@@ -440,32 +453,35 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
caosdb_connection_connection_manager_get_default_connection
(
&
connection
);
// Create and insert a property, ...
std
::
cout
<<
"Creating a property..."
<<
std
::
endl
;
caosdb_entity_entity
original_prop
;
caosdb_entity_create_entity
(
&
original_prop
);
caosdb_entity_entity_set_name
(
&
original_prop
,
"TestProp"
);
caosdb_entity_entity_set_
datatyp
e
(
&
original_prop
,
"
TEXT
"
);
caosdb_entity_entity_set_
rol
e
(
&
original_prop
,
"
Property"
);
caosdb_entity_entity_set_
rol
e
(
&
original_prop
,
"
PROPERTY
"
);
caosdb_entity_entity_set_
datatyp
e
(
&
original_prop
,
"
TEXT"
,
false
,
false
);
std
::
cout
<<
"Inserting a property..."
<<
std
::
endl
;
caosdb_transaction_transaction
prop_insertion
;
caosdb_connection_connection_create_transaction
(
&
connection
,
&
prop_insertion
);
caosdb_transaction_transaction_insert_entity
(
&
prop_insertion
,
&
original_prop
);
int
return_code
(
caosdb_transaction_transaction_execute
(
&
prop_insertion
));
EXPECT_EQ
(
return_code
,
0
);
std
::
cout
<<
"Checking result..."
<<
std
::
endl
;
caosdb_transaction_result_set
prop_results
;
caosdb_transaction_transaction_get_result_set
(
&
prop_insertion
,
&
prop_results
);
caosdb_entity_entity
inserted_prop
;
caosdb_transaction_result_set_at
(
&
prop_results
,
&
inserted_prop
,
0
);
char
prop_id
[
255
]
=
{
"id"
}
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_prop
,
prop_id
);
char
*
prop_id
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_prop
,
&
prop_id
);
// ... a record type with this property, ...
caosdb_entity_entity
original_rt
;
caosdb_entity_create_entity
(
&
original_rt
);
caosdb_entity_entity_set_name
(
&
original_rt
,
"TestType"
);
caosdb_entity_entity_set_role
(
&
original_rt
,
"R
ecordType
"
);
caosdb_entity_entity_set_role
(
&
original_rt
,
"R
ECORD_TYPE
"
);
caosdb_entity_property
rt_prop
;
caosdb_entity_create_property
(
&
rt_prop
);
...
...
@@ -482,14 +498,14 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
caosdb_transaction_transaction_get_result_set
(
&
rt_insertion
,
&
rt_results
);
caosdb_entity_entity
inserted_rt
;
caosdb_transaction_result_set_at
(
&
rt_results
,
&
inserted_rt
,
0
);
char
rt_id
[
255
]
=
{
"id"
}
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_rt
,
rt_id
);
char
*
rt_id
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_rt
,
&
rt_id
);
// ... and a record with this record type as a parent.
caosdb_entity_entity
original_rec
;
caosdb_entity_create_entity
(
&
original_rec
);
caosdb_entity_entity_set_name
(
&
original_rec
,
"TestRec"
);
caosdb_entity_entity_set_role
(
&
original_rec
,
"R
ecord
"
);
caosdb_entity_entity_set_role
(
&
original_rec
,
"R
ECORD
"
);
caosdb_entity_parent
rec_parent
;
caosdb_entity_create_parent
(
&
rec_parent
);
caosdb_entity_parent_set_id
(
&
rec_parent
,
rt_id
);
...
...
@@ -497,7 +513,7 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
caosdb_entity_property
rec_prop
;
caosdb_entity_create_property
(
&
rec_prop
);
caosdb_entity_property_set_id
(
&
rec_prop
,
prop_id
);
caosdb_entity_property_set_value
(
&
rec_prop
,
"Bla"
);
caosdb_entity_property_set_
string_
value
(
&
rec_prop
,
"Bla"
);
caosdb_entity_entity_append_property
(
&
original_rec
,
&
rec_prop
);
caosdb_transaction_transaction
rec_insertion
;
...
...
@@ -510,8 +526,8 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
caosdb_transaction_transaction_get_result_set
(
&
rec_insertion
,
&
rec_results
);
caosdb_entity_entity
inserted_rec
;
caosdb_transaction_result_set_at
(
&
rec_results
,
&
inserted_rec
,
0
);
char
rec_id
[
255
]
=
{
"id"
}
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_rec
,
rec_id
);
char
*
rec_id
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_rec
,
&
rec_id
);
// Retrieve the record again for comparison
caosdb_transaction_transaction
retrieve_transaction
;
...
...
@@ -526,10 +542,10 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
&
retrieve_result
);
caosdb_entity_entity
retrieved_rec
;
caosdb_transaction_result_set_at
(
&
retrieve_result
,
&
retrieved_rec
,
0
);
char
in
[
255
]
=
{
"abc"
}
;
// NOLINT
char
out
[
255
]
=
{
"abc"
}
;
// NOLINT
caosdb_entity_entity_get_name
(
&
original_rec
,
in
);
caosdb_entity_entity_get_name
(
&
retrieved_rec
,
out
);
char
*
in
=
nullptr
;
// NOLINT
char
*
out
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_name
(
&
original_rec
,
&
in
);
caosdb_entity_entity_get_name
(
&
retrieved_rec
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
int
count
[]
=
{
0
};
// NOLINT
caosdb_entity_entity_get_properties_size
(
&
retrieved_rec
,
count
);
...
...
@@ -539,19 +555,19 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
caosdb_entity_parent
retrieved_parent
;
caosdb_entity_entity_get_parent
(
&
retrieved_rec
,
&
retrieved_parent
,
0
);
caosdb_entity_entity_get_name
(
&
original_rt
,
in
);
caosdb_entity_parent_get_name
(
&
retrieved_parent
,
out
);
caosdb_entity_entity_get_name
(
&
original_rt
,
&
in
);
caosdb_entity_parent_get_name
(
&
retrieved_parent
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_parent_get_id
(
&
retrieved_parent
,
out
);
caosdb_entity_parent_get_id
(
&
retrieved_parent
,
&
out
);
EXPECT_EQ
(
strcmp
(
rt_id
,
out
),
0
);
caosdb_entity_property
retrieved_property
;
caosdb_entity_entity_get_property
(
&
retrieved_rec
,
&
retrieved_property
,
0
);
caosdb_entity_entity_get_name
(
&
original_prop
,
in
);
caosdb_entity_property_get_name
(
&
retrieved_property
,
out
);
caosdb_entity_entity_get_name
(
&
original_prop
,
&
in
);
caosdb_entity_property_get_name
(
&
retrieved_property
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_entity_property_get_value
(
&
rec_prop
,
in
);
caosdb_entity_property_get_value
(
&
retrieved_property
,
out
);
caosdb_entity_property_get_
string_
value
(
&
rec_prop
,
&
in
);
caosdb_entity_property_get_
string_
value
(
&
retrieved_property
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
caosdb_transaction_delete_transaction
(
&
retrieve_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