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
950e0848
Verified
Commit
950e0848
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
Removed test_file_transmission.cpp
parent
ff0558ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!9
F consolidation
Pipeline
#12226
passed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+0
-1
0 additions, 1 deletion
test/CMakeLists.txt
test/test_file_transmission.cpp
+0
-163
0 additions, 163 deletions
test/test_file_transmission.cpp
with
0 additions
and
164 deletions
test/CMakeLists.txt
+
0
−
1
View file @
950e0848
...
...
@@ -25,7 +25,6 @@ set(test_cases
test_connection
test_transaction
test_list_properties
test_file_transmission
test_ccaosdb
)
...
...
This diff is collapsed.
Click to expand it.
test/test_file_transmission.cpp
deleted
100644 → 0
+
0
−
163
View file @
ff0558ec
/*
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include
"caosdb/connection.h"
// for Connection, ConnectionManager
#include
"caosdb/entity.h"
#include
"caosdb/entity/v1alpha1/main.pb.h"
#include
"caosdb/transaction.h"
// for Transaction, UniqueRe...
#include
"gtest/gtest-message.h"
// for Message
#include
"gtest/gtest-test-part.h"
// for TestPartResult, SuiteApiResolver
#include
"gtest/gtest_pred_impl.h"
// for Test, EXPECT_EQ, AssertionResult
#include
<memory>
// for unique_ptr, allocator, __shar...
#include
<string>
// for string
namespace
caosdb
::
transaction
{
using
caosdb
::
entity
::
Entity
;
using
caosdb
::
entity
::
v1alpha1
::
FileDownloadResponse
;
using
caosdb
::
entity
::
v1alpha1
::
FileUploadResponse
;
using
caosdb
::
entity
::
v1alpha1
::
RegisterFileDownloadResponse
;
using
caosdb
::
entity
::
v1alpha1
::
RegisterFileUploadResponse
;
using
caosdb
::
entity
::
v1alpha1
::
RegistrationStatus
;
using
caosdb
::
entity
::
v1alpha1
::
TransmissionStatus
;
// TODO(tf) this file is currently not used (see CMakeLists.txt)
// Is it still necessary or is it obsolete due to test_transaction.cpp?
// RegisterFileDownloadResponse is currently not defined by proto or the h
// file.
class
test_file_transmission
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{}
void
TearDown
()
override
{
// TODO(tf): delete all created entities
}
};
TEST_F
(
test_file_transmission
,
register_file_upload
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
transaction
(
connection
->
CreateTransaction
());
RegisterFileUploadResponse
response
;
EXPECT_EQ
(
response
.
status
(),
RegistrationStatus
::
REGISTRATION_STATUS_UNSPECIFIED
);
transaction
->
RegisterUploadFile
(
&
response
);
EXPECT_EQ
(
response
.
status
(),
RegistrationStatus
::
REGISTRATION_STATUS_ACCEPTED
);
EXPECT_FALSE
(
response
.
registration_id
().
empty
());
}
TEST_F
(
test_file_transmission
,
file_upload
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
transaction
(
connection
->
CreateTransaction
());
RegisterFileUploadResponse
registration_response
;
transaction
->
RegisterUploadFile
(
&
registration_response
);
ASSERT_EQ
(
registration_response
.
status
(),
RegistrationStatus
::
REGISTRATION_STATUS_ACCEPTED
);
auto
registration_id
=
registration_response
.
registration_id
();
FileUploadResponse
upload_response
;
transaction
->
UploadFile
(
&
upload_response
,
registration_id
);
EXPECT_EQ
(
upload_response
.
status
(),
TransmissionStatus
::
TRANSMISSION_STATUS_GO_ON
);
}
TEST_F
(
test_file_transmission
,
file_insertion
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
transaction
(
connection
->
CreateTransaction
());
RegisterFileUploadResponse
registration_response
;
transaction
->
RegisterUploadFile
(
&
registration_response
);
ASSERT_EQ
(
registration_response
.
status
(),
RegistrationStatus
::
REGISTRATION_STATUS_ACCEPTED
);
auto
registration_id
=
registration_response
.
registration_id
();
FileUploadResponse
upload_response
;
transaction
->
UploadFile
(
&
upload_response
,
registration_id
);
Entity
file_entity
;
file_entity
.
SetRole
(
"File"
);
file_entity
.
SetFileTransmissionId
(
registration_id
,
"test.txt"
);
file_entity
.
SetFilePath
(
"test.txt"
);
transaction
->
InsertEntity
(
&
file_entity
);
transaction
->
Execute
();
auto
cleanup_transaction
(
connection
->
CreateTransaction
());
cleanup_transaction
->
DeleteById
(
transaction
->
GetResultSet
().
At
(
0
).
GetId
());
cleanup_transaction
->
Execute
();
}
TEST_F
(
test_file_transmission
,
file_download
)
{
const
auto
&
connection
=
caosdb
::
connection
::
ConnectionManager
::
GetDefaultConnection
();
auto
upload_transaction
(
connection
->
CreateTransaction
());
RegisterFileUploadResponse
upload_registration_response
;
upload_transaction
->
RegisterUploadFile
(
&
upload_registration_response
);
ASSERT_EQ
(
upload_registration_response
.
status
(),
RegistrationStatus
::
REGISTRATION_STATUS_ACCEPTED
);
auto
registration_id
=
upload_registration_response
.
registration_id
();
FileUploadResponse
upload_response
;
upload_transaction
->
UploadFile
(
&
upload_response
,
registration_id
);
Entity
file_entity
;
file_entity
.
SetRole
(
"File"
);
file_entity
.
SetFileTransmissionId
(
registration_id
,
"test.txt"
);
file_entity
.
SetFilePath
(
"test.txt"
);
upload_transaction
->
InsertEntity
(
&
file_entity
);
upload_transaction
->
Execute
();
// Download by entity_id
auto
download_transaction
(
connection
->
CreateTransaction
());
RegisterFileDownloadResponse
download_registration_response
;
RegisterFileDownloadRequest
download_registration_request
;
download_registration_request
.
add_files
()
->
set_entity_id
(
upload_transaction
->
GetResultSet
().
At
(
0
).
GetId
());
download_transaction
->
RegisterDownloadFile
(
download_registration_request
,
&
download_registration_response
);
ASSERT_EQ
(
download_registration_response
.
status
(),
RegistrationStatus
::
REGISTRATION_STATUS_ACCEPTED
);
FileDownloadResponse
download_response
;
download_transaction
->
DownloadFile
(
&
download_response
,
download_registration_response
);
EXPECT_EQ
(
download_response
.
chunk
().
data
(),
"this is some data"
);
// CLEANUP
auto
cleanup_transaction
(
connection
->
CreateTransaction
());
cleanup_transaction
->
DeleteById
(
upload_transaction
->
GetResultSet
().
At
(
0
).
GetId
());
cleanup_transaction
->
Execute
();
}
}
// 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