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
bf337c11
Commit
bf337c11
authored
3 years ago
by
florian
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-consolidation' into f-consolidate-c
parents
f638ff39
8f310e43
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!10
ENH: Test datatypes and values in Extern C interface
Pipeline
#12331
passed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
This commit is part of merge request
!10
. Comments created here will be created in the context of that merge request.
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_transaction.cpp
+127
-0
127 additions, 0 deletions
test/test_transaction.cpp
with
127 additions
and
0 deletions
test/test_transaction.cpp
+
127
−
0
Edit
View file @
bf337c11
...
...
@@ -776,4 +776,131 @@ TEST_F(test_transaction, test_file_up_n_download) {
}
}
/*
* Test a small worklfow
*/
TEST_F
(
test_transaction
,
test_full_workflow
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
// ###### Create Data Model ######
Entity
dataRT
;
dataRT
.
SetRole
(
Role
::
RECORD_TYPE
);
dataRT
.
SetName
(
"DataRT"
);
Entity
voltage
;
voltage
.
SetRole
(
Role
::
PROPERTY
);
voltage
.
SetName
(
"voltage"
);
voltage
.
SetUnit
(
"V"
);
voltage
.
SetDataType
(
AtomicDataType
::
DOUBLE
);
Entity
notes
;
notes
.
SetRole
(
Role
::
PROPERTY
);
notes
.
SetName
(
"notes"
);
notes
.
SetDataType
(
AtomicDataType
::
TEXT
);
Entity
participants
;
participants
.
SetRole
(
Role
::
PROPERTY
);
participants
.
SetName
(
"participants"
);
participants
.
SetDataType
(
AtomicDataType
::
INTEGER
);
// participants.SetDataType(ListDataType::);
Entity
success
;
success
.
SetRole
(
Role
::
PROPERTY
);
success
.
SetName
(
"success"
);
success
.
SetDataType
(
AtomicDataType
::
BOOLEAN
);
Entity
experiment
;
experiment
.
SetRole
(
Role
::
RECORD_TYPE
);
experiment
.
SetName
(
"Experiment"
);
// TODO(henrik): creating this extra Property (additionally to the Entity
// above) is VERY clumsy
Property
volt_for_rt
;
volt_for_rt
.
SetName
(
voltage
.
GetName
());
volt_for_rt
.
SetImportance
(
Importance
::
RECOMMENDED
);
experiment
.
AppendProperty
(
volt_for_rt
);
Property
notes_for_rt2
;
notes_for_rt2
.
SetName
(
notes
.
GetName
());
notes_for_rt2
.
SetImportance
(
Importance
::
RECOMMENDED
);
experiment
.
AppendProperty
(
notes_for_rt2
);
Property
part_for_rt3
;
part_for_rt3
.
SetName
(
participants
.
GetName
());
part_for_rt3
.
SetImportance
(
Importance
::
SUGGESTED
);
experiment
.
AppendProperty
(
part_for_rt3
);
Property
succ_for_rt
;
succ_for_rt
.
SetName
(
success
.
GetName
());
succ_for_rt
.
SetImportance
(
Importance
::
SUGGESTED
);
experiment
.
AppendProperty
(
succ_for_rt
);
auto
insert_transaction
(
connection
->
CreateTransaction
());
insert_transaction
->
InsertEntity
(
&
dataRT
);
auto
insert_status
=
insert_transaction
->
Execute
();
const
auto
&
insert_results
=
insert_transaction
->
GetResultSet
();
const
auto
&
inserted_ent
=
insert_results
.
at
(
0
);
ASSERT_FALSE
(
inserted_ent
.
GetId
().
empty
());
ASSERT_FALSE
(
inserted_ent
.
HasErrors
());
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
voltage
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
notes
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
participants
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
success
);
insert_status
=
insert_transaction
->
Execute
();
insert_transaction
=
connection
->
CreateTransaction
();
insert_transaction
->
InsertEntity
(
&
experiment
);
insert_status
=
insert_transaction
->
Execute
();
auto
retr_transaction
(
connection
->
CreateTransaction
());
retr_transaction
->
Query
(
"FIND Experiment"
);
retr_transaction
->
Execute
();
EXPECT_EQ
(
retr_transaction
->
GetResultSet
().
size
(),
1
);
Parent
experiment_parent
;
experiment_parent
.
SetName
(
"Experiment"
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
Entity
experiment_rec
;
experiment_rec
.
SetRole
(
Role
::
RECORD
);
experiment_rec
.
AppendParent
(
experiment_parent
);
volt_for_rt
.
SetValue
(
1.6
);
experiment_rec
.
AppendProperty
(
volt_for_rt
);
notes_for_rt2
.
SetValue
(
"This is important!"
);
experiment_rec
.
AppendProperty
(
notes_for_rt2
);
part_for_rt3
.
SetValue
(
static_cast
<
int64_t
>
(
6
));
experiment_rec
.
AppendProperty
(
part_for_rt3
);
succ_for_rt
.
SetValue
(
true
);
experiment_rec
.
AppendProperty
(
succ_for_rt
);
auto
rec_insert_transaction
(
connection
->
CreateTransaction
());
rec_insert_transaction
->
InsertEntity
(
&
experiment_rec
);
std
::
cout
<<
"before ..."
<<
std
::
endl
;
insert_status
=
rec_insert_transaction
->
Execute
();
std
::
cout
<<
"after ..."
<<
std
::
endl
;
}
retr_transaction
=
connection
->
CreateTransaction
();
retr_transaction
->
Query
(
"FIND Record Experiment"
);
retr_transaction
->
Execute
();
EXPECT_EQ
(
retr_transaction
->
GetResultSet
().
size
(),
8
);
auto
to_be_updated
=
retr_transaction
->
GetResultSet
().
at
(
0
);
// TODO(henrik) using the index for deletion is very inconvenient
to_be_updated
.
RemoveProperty
(
0
);
to_be_updated
.
SetName
(
"changedone"
);
auto
update_transaction
(
connection
->
CreateTransaction
());
update_transaction
->
UpdateEntity
(
&
to_be_updated
);
update_transaction
->
Execute
();
retr_transaction
=
connection
->
CreateTransaction
();
retr_transaction
->
Query
(
"FIND Record Experiment with name=changedone"
);
retr_transaction
->
Execute
();
EXPECT_EQ
(
retr_transaction
->
GetResultSet
().
size
(),
1
);
}
}
// 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