Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Julia Integration Tests
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 Julia Integration Tests
Commits
5c2327c3
Commit
5c2327c3
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add tests for transactions
parent
1e8f1caa
No related branches found
No related tags found
1 merge request
!3
ENH: Test queries and entity retrieval
Pipeline
#12077
failed
3 years ago
Stage: info
Stage: code-style
Stage: setup
Stage: cert
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/runtests.jl
+72
-0
72 additions, 0 deletions
test/runtests.jl
with
72 additions
and
0 deletions
test/runtests.jl
+
72
−
0
View file @
5c2327c3
...
...
@@ -65,4 +65,76 @@ end
@test
CaosDB
.
Connection
.
connect_manually
()
!=
nothing
end
@testset
"Test transaction"
begin
# transactions can be created from connection names or objects
connection
=
CaosDB
.
Connection
.
connect
()
@test
create_transaction
(
connection
)
!=
nothing
@test
create_transaction
()
!=
nothing
@test
create_transaction
(
"julialib-integrationtest"
)
!=
nothing
# Construct and execute a transaction manually
transaction
=
create_transaction
()
add_query
(
transaction
,
"FIND ENTITY WITH id=-1"
)
execute
(
transaction
)
result_set
=
get_result_set
(
transaction
)
results
=
get_results
(
result_set
)
# There is no entity with id=-1
@test
length
(
results
)
==
0
# result-sets can be omitted
transaction_results
=
get_results
(
transaction
)
@test
length
(
transaction_results
)
==
0
# No count query, so this should be -1
@test
get_count_result
(
transaction
)
==
-
1
# Also works directly, with or without connection being
# specified.
query_results1
=
execute_query
(
"FIND ENTITY WITH id=-1"
)
@test
length
(
query_results1
)
==
0
query_results2
=
execute_query
(
"FIND ENTITY WITH id=-1"
,
"julialib-integrationtest"
)
@test
length
(
query_results2
)
==
0
query_results3
=
execute_query
(
"FIND ENTITY WITH id=-1"
,
connection
)
@test
length
(
query_results3
)
==
0
# COUNT queries have to be conducted manually
count_transaction
=
create_transaction
()
add_query
(
transaction
,
"COUNT ENTITY WITH id=-1"
)
execute
(
transaction
)
# Still an empty result set
@test
get_count_result
(
transaction
)
==
0
end
@testset
"Test entity retrieval"
begin
single_retrieve_transaction
=
create_transaction
()
add_retrieve_by_id
(
single_retrieve_transaction
,
"20"
)
execute
(
single_retrieve_transaction
)
results
=
get_results
(
single_retrieve_transaction
)
@test
length
(
results
)
==
1
@test
has_errors
(
results
[
1
])
==
false
@test
get_name
(
results
[
1
])
==
"name"
multi_retrieve_transaction
=
create_transaction
()
add_retrieve_by_id
(
multi_retrieve_transaction
,
[
"20"
,
"21"
])
execute
(
multi_retrieve_transaction
)
results
=
get_results
(
multi_retrieve_transaction
)
@test
length
(
results
)
==
2
@test
get_name
(
results
[
1
])
==
"name"
@test
get_name
(
results
[
2
])
==
"unit"
# Helper functions
ent
=
retrieve
(
"20"
)
@test
get_name
(
ent
)
==
"name"
results
=
retrieve
([
"20"
,
"21"
])
@test
length
(
results
)
==
2
@test
get_name
(
results
[
1
])
==
"name"
@test
get_name
(
results
[
2
])
==
"unit"
# id=22 doesn't exist
@test_throws
CaosDB
.
Exceptions
.
GenericCaosDBException
retrieve
(
"22"
)
@test_throws
CaosDB
.
Exceptions
.
GenericCaosDBException
retrieve
([
"20"
,
"21"
,
"22"
])
end
end
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