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
10398ee9
Verified
Commit
10398ee9
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: files
parent
9785bdb4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8
F files
Pipeline
#11913
failed
3 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/CMakeLists.txt
+1
-1
1 addition, 1 deletion
test/CMakeLists.txt
test/test_transaction.cpp
+38
-16
38 additions, 16 deletions
test/test_transaction.cpp
with
39 additions
and
17 deletions
test/CMakeLists.txt
+
1
−
1
View file @
10398ee9
...
@@ -82,7 +82,7 @@ if(LINTING)
...
@@ -82,7 +82,7 @@ if(LINTING)
"--warnings-as-errors=*"
"--warnings-as-errors=*"
"--fix"
)
"--fix"
)
set
(
_CMAKE_CXX_CLANG_TIDY_CHECKS
set
(
_CMAKE_CXX_CLANG_TIDY_CHECKS
"--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity"
)
"--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity
,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes
"
)
endif
()
endif
()
else
()
else
()
message
(
STATUS
"LINTING is OFF"
)
message
(
STATUS
"LINTING is OFF"
)
...
...
This diff is collapsed.
Click to expand it.
test/test_transaction.cpp
+
38
−
16
View file @
10398ee9
...
@@ -18,31 +18,52 @@
...
@@ -18,31 +18,52 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
*/
*/
#include
"caosdb/connection.h"
// for Connection, ConnectionManager
#include
"caosdb/connection.h"
// for Connection, ConnectionManager
#include
"caosdb/entity.h"
// for Entity, Messages, Message
#include
"caosdb/entity.h"
// for Entity, Messages, Message
#include
"caosdb/filestreaming/FileWriter.h"
// for FileWriter
#include
"caosdb/message_code.h"
// for ENTITY_DOES_NOT_EXIST, Messag...
#include
"caosdb/message_code.h"
// for ENTITY_DOES_NOT_EXIST, Messag...
#include
"caosdb/status_code.h"
// for SUCCESS, StatusCode
#include
"caosdb/status_code.h"
// for SUCCESS, StatusCode
#include
"caosdb/transaction.h"
// for Entity, Transaction, UniqueRe...
#include
"caosdb/transaction.h"
// for Entity, Transaction, UniqueRe...
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#include
<boost/filesystem/path.hpp>
#include
<boost/filesystem/path.hpp>
// for path
#include
"gtest/gtest-message.h"
// for Message
#include
<boost/filesystem/operations.hpp>
// for remove
#include
"gtest/gtest-test-part.h"
// for TestPartResult, SuiteApiResolver
#include
<boost/filesystem/path_traits.hpp>
// for filesystem
#include
"gtest/gtest_pred_impl.h"
// for Test, EXPECT_EQ, AssertionResult
#include
<gtest/gtest-message.h>
// for Message
#include
<iostream>
#include
<gtest/gtest-test-part.h>
// for TestPartResult, SuiteApiResolver
#include
<memory>
// for unique_ptr, allocator, __shar...
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, AssertionResult
#include
<string>
// for string
#include
<memory>
// for unique_ptr, allocator, __shar...
#include
<vector>
// for vector
#include
<string>
// for string
#include
<vector>
// for vector
namespace
fs
=
boost
::
filesystem
;
namespace
caosdb
::
transaction
{
namespace
caosdb
::
transaction
{
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
MessageCode
;
using
caosdb
::
entity
::
MessageCode
;
using
caosdb
::
entity
::
Parent
;
using
caosdb
::
entity
::
Parent
;
using
caosdb
::
entity
::
Property
;
using
caosdb
::
entity
::
Property
;
using
FileExchange
::
FileWriter
;
class
test_transaction
:
public
::
testing
::
Test
{
class
test_transaction
:
public
::
testing
::
Test
{
private:
fs
::
path
test_upload_file_1
;
fs
::
path
test_download_file_1
;
protected:
protected:
void
SetUp
()
override
{}
void
SetUp
()
override
{
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"
);
FileWriter
writer
(
test_upload_file_1
);
std
::
string
buffer
(
1024
,
'c'
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
writer
.
write
(
buffer
);
}
}
void
TearDown
()
override
{
void
TearDown
()
override
{
fs
::
remove
(
test_upload_file_1
);
fs
::
remove
(
test_download_file_1
);
const
auto
&
connection
=
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
query_transaction
(
connection
->
CreateTransaction
());
auto
query_transaction
(
connection
->
CreateTransaction
());
...
@@ -665,7 +686,7 @@ TEST_F(test_transaction, test_file_upload) {
...
@@ -665,7 +686,7 @@ TEST_F(test_transaction, test_file_upload) {
Entity
file
;
Entity
file
;
file
.
SetRole
(
"File"
);
file
.
SetRole
(
"File"
);
file
.
SetFilePath
(
"test.txt"
);
file
.
SetFilePath
(
"test.txt"
);
file
.
SetLocalPath
(
"
test
.txt"
);
file
.
SetLocalPath
(
test
_upload_file_1
);
auto
insert_transaction
(
connection
->
CreateTransaction
());
auto
insert_transaction
(
connection
->
CreateTransaction
());
insert_transaction
->
InsertEntity
(
&
file
);
insert_transaction
->
InsertEntity
(
&
file
);
...
@@ -691,7 +712,7 @@ TEST_F(test_transaction, test_file_download) {
...
@@ -691,7 +712,7 @@ TEST_F(test_transaction, test_file_download) {
Entity
file
;
Entity
file
;
file
.
SetRole
(
"File"
);
file
.
SetRole
(
"File"
);
file
.
SetFilePath
(
"test.txt"
);
file
.
SetFilePath
(
"test.txt"
);
file
.
SetLocalPath
(
"
test
.txt"
);
file
.
SetLocalPath
(
test
_upload_file_1
);
auto
insert_transaction
(
connection
->
CreateTransaction
());
auto
insert_transaction
(
connection
->
CreateTransaction
());
insert_transaction
->
InsertEntity
(
&
file
);
insert_transaction
->
InsertEntity
(
&
file
);
...
@@ -704,8 +725,8 @@ TEST_F(test_transaction, test_file_download) {
...
@@ -704,8 +725,8 @@ TEST_F(test_transaction, test_file_download) {
ASSERT_FALSE
(
inserted_file
.
HasErrors
());
ASSERT_FALSE
(
inserted_file
.
HasErrors
());
auto
download_transaction
(
connection
->
CreateTransaction
());
auto
download_transaction
(
connection
->
CreateTransaction
());
download_transaction
->
RetrieveAndDownloadFilesById
(
inserted_file
.
GetId
(),
download_transaction
->
RetrieveAndDownloadFilesById
(
"downloaded.txt"
);
inserted_file
.
GetId
(),
test_download_file_1
.
string
()
);
download_transaction
->
ExecuteAsynchronously
();
download_transaction
->
ExecuteAsynchronously
();
download_transaction
->
WaitForIt
();
download_transaction
->
WaitForIt
();
...
@@ -715,7 +736,8 @@ TEST_F(test_transaction, test_file_download) {
...
@@ -715,7 +736,8 @@ TEST_F(test_transaction, test_file_download) {
const
auto
&
downloaded_file
=
download_results
.
At
(
0
);
const
auto
&
downloaded_file
=
download_results
.
At
(
0
);
ASSERT_FALSE
(
downloaded_file
.
GetId
().
empty
());
ASSERT_FALSE
(
downloaded_file
.
GetId
().
empty
());
ASSERT_FALSE
(
downloaded_file
.
HasErrors
());
ASSERT_FALSE
(
downloaded_file
.
HasErrors
());
EXPECT_EQ
(
downloaded_file
.
GetLocalPath
().
string
(),
"downloaded.txt"
);
EXPECT_EQ
(
downloaded_file
.
GetLocalPath
().
string
(),
test_download_file_1
.
string
());
}
}
}
// namespace caosdb::transaction
}
// 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