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
a0c74115
Verified
Commit
a0c74115
authored
2 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: SELECT for GRPC API
parent
a81a099f
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!28
Release 0.2.2
,
!27
F grpc select
Pipeline
#30376
passed
2 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test_list_properties.cpp
+24
-0
24 additions, 0 deletions
test/test_list_properties.cpp
test/test_select.cpp
+43
-4
43 additions, 4 deletions
test/test_select.cpp
with
67 additions
and
4 deletions
test/test_list_properties.cpp
+
24
−
0
View file @
a0c74115
...
...
@@ -221,4 +221,28 @@ TEST_F(test_list_properties, insert_list_of_bool) {
EXPECT_FALSE
(
value
.
GetAsVector
().
at
(
1
).
GetAsBool
());
}
TEST_F
(
test_list_properties
,
insert_list_non_list_datatype
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insertion_prop
(
connection
->
CreateTransaction
());
Entity
abstract_list_property
;
abstract_list_property
.
SetRole
(
Role
::
PROPERTY
);
abstract_list_property
.
SetName
(
"TestProp"
);
abstract_list_property
.
SetDataType
(
AtomicDataType
::
TEXT
);
abstract_list_property
.
SetValue
(
std
::
vector
<
std
::
string
>
{
"item1"
,
"item2"
,
"item3"
});
insertion_prop
->
InsertEntity
(
&
abstract_list_property
);
std
::
cout
<<
"response "
<<
insertion_prop
->
ResponseToString
();
insertion_prop
->
ExecuteAsynchronously
();
insertion_prop
->
WaitForIt
();
EXPECT_TRUE
(
insertion_prop
->
GetStatus
().
IsTerminated
());
EXPECT_TRUE
(
insertion_prop
->
GetStatus
().
IsError
());
auto
query_transaction
(
connection
->
CreateTransaction
());
query_transaction
->
Query
(
"FIND ENTITY TestProp"
);
query_transaction
->
Execute
();
EXPECT_EQ
(
query_transaction
->
GetResultSet
().
size
(),
0
);
}
}
// namespace caosdb::entity
This diff is collapsed.
Click to expand it.
test/test_select.cpp
+
43
−
4
View file @
a0c74115
...
...
@@ -69,12 +69,12 @@ public:
}
}
static
auto
CreateTestProp
(
const
std
::
string
&
name
,
AtomicDataType
data_type
)
->
Entity
{
static
auto
CreateTestProp
(
const
std
::
string
&
name
,
AtomicDataType
data_type
,
bool
isList
=
false
)
->
Entity
{
Entity
entity
;
entity
.
SetRole
(
Role
::
PROPERTY
);
entity
.
SetName
(
name
);
entity
.
SetDescription
(
"Prop Description "
+
name
);
entity
.
SetDataType
(
data_type
);
entity
.
SetDataType
(
data_type
,
isList
);
return
entity
;
}
...
...
@@ -86,12 +86,12 @@ public:
return
entity
;
}
static
auto
CreateTestProp
(
const
std
::
string
&
name
,
const
std
::
string
&
data_type
)
->
Entity
{
static
auto
CreateTestProp
(
const
std
::
string
&
name
,
const
std
::
string
&
data_type
,
bool
isList
=
false
)
->
Entity
{
Entity
entity
;
entity
.
SetRole
(
Role
::
PROPERTY
);
entity
.
SetName
(
name
);
entity
.
SetDescription
(
"Prop Description "
+
name
);
entity
.
SetDataType
(
data_type
);
entity
.
SetDataType
(
data_type
,
isList
);
return
entity
;
}
...
...
@@ -120,13 +120,17 @@ protected:
void
SetUp
()
override
{
DeleteEntities
();
// Test Entities
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
insert_transaction
(
connection
->
CreateTransaction
());
// 1. Two RecordTypes
auto
rt
=
CreateTestRT
();
auto
rt2
=
CreateTestRT
();
rt2
.
SetName
(
"TestRT2"
);
insert_transaction
->
InsertEntity
(
&
rt
);
insert_transaction
->
InsertEntity
(
&
rt2
);
// 2. Six Scalar Properties
auto
p
=
CreateTestProp
(
"TestProp"
,
AtomicDataType
::
TEXT
);
insert_transaction
->
InsertEntity
(
&
p
);
p
=
CreateTestProp
(
"TestProp2"
,
AtomicDataType
::
TEXT
);
...
...
@@ -142,7 +146,11 @@ protected:
p
=
CreateTestProp
(
"TestPropBool"
,
AtomicDataType
::
BOOLEAN
);
insert_transaction
->
InsertEntity
(
&
p
);
// 3. A List Property
p
=
CreateTestProp
(
"TestListTextProp"
,
AtomicDataType
::
TEXT
,
true
);
insert_transaction
->
InsertEntity
(
&
p
);
// 4. A Record which can be references by others
auto
reference_entity
=
test_select
::
CreateRecord
(
"TestProp3"
,
Value
(
"val3"
));
Property
property
;
property
.
SetName
(
"TestPropDouble"
);
...
...
@@ -155,6 +163,7 @@ protected:
parent
.
SetName
(
"TestRT2"
);
reference_entity
.
AppendParent
(
parent
);
insert_transaction
->
InsertEntity
(
&
reference_entity
);
insert_transaction
->
Execute
();
}
...
...
@@ -506,5 +515,35 @@ TEST_F(test_select, test_select_reference_entitys_propertys_id) {
}
}
/*
* Test select a list.
*/
TEST_F
(
test_select
,
test_select_list
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
entity
=
test_select
::
CreateRecord
(
"TestRT2"
,
Value
());
Property
listp
;
listp
.
SetName
(
"TestListTextProp"
);
listp
.
SetValue
(
std
::
vector
<
std
::
string
>
{
"item1"
,
"item2"
,
"item3"
});
entity
.
AppendProperty
(
listp
);
test_select
::
InsertEntity
(
&
entity
);
auto
query_transaction
(
connection
->
CreateTransaction
());
query_transaction
->
Query
(
"SELECT TestListTextProp FROM Record TestRT"
);
query_transaction
->
Execute
();
EXPECT_EQ
(
query_transaction
->
GetResultTable
().
GetHeader
().
size
(),
1
);
for
(
const
auto
&
column
:
query_transaction
->
GetResultTable
().
GetHeader
())
{
EXPECT_EQ
(
column
.
GetName
(),
"TestListTextProp"
);
}
EXPECT_EQ
(
query_transaction
->
GetResultTable
().
size
(),
1
);
for
(
const
auto
&
row
:
query_transaction
->
GetResultTable
().
GetRows
())
{
EXPECT_EQ
(
row
.
GetValue
(
"TestListTextProp"
).
GetAsVector
().
at
(
0
).
GetAsString
(),
"item1"
);
EXPECT_EQ
(
row
.
GetValue
(
"TestListTextProp"
).
GetAsVector
().
at
(
1
).
GetAsString
(),
"item2"
);
EXPECT_EQ
(
row
.
GetValue
(
"TestListTextProp"
).
GetAsVector
().
at
(
2
).
GetAsString
(),
"item3"
);
}
}
}
// 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