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
613b7065
Commit
613b7065
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
TST: add int test for file up and download
parent
c1fe7633
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
ENH: Test insert/update/delete and files in Extern C
Pipeline
#12434
failed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_ccaosdb.cpp
+81
-7
81 additions, 7 deletions
test/test_ccaosdb.cpp
with
81 additions
and
7 deletions
test/test_ccaosdb.cpp
+
81
−
7
View file @
613b7065
...
...
@@ -18,24 +18,46 @@
* 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/message_code.h"
// for MessageCode
#include
"caosdb/status_code.h"
// for StatusCode
#include
"ccaosdb.h"
// for caosdb_info_version_info, caosdb_...
#include
<cstring>
// for strcmp
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult
#include
"caosdb/file_transmission/file_reader.h"
// for FileReader
#include
"caosdb/file_transmission/file_writer.h"
// for FileWriter
#include
"caosdb/message_code.h"
// for MessageCode
#include
"caosdb/status_code.h"
// for StatusCode
#include
"ccaosdb.h"
// for caosdb_info_version_info, caosdb_...
#include
<boost/filesystem/path.hpp>
// for path
#include
<boost/filesystem/path_traits.hpp>
// for filesystem
#include
<cstring>
// for strcmp
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for TestPartResult
#include
<gtest/gtest_pred_impl.h>
// for Test, EXPECT_EQ, SuiteApiResolver
#include
<iostream>
#include
<memory>
// for allocator, unique_ptr
namespace
fs
=
boost
::
filesystem
;
class
test_ccaosdb
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{}
fs
::
path
test_upload_file_1
;
fs
::
path
test_download_file_1
;
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"
);
// fill the file that shall be uploaded
caosdb
::
transaction
::
FileWriter
writer
(
test_upload_file_1
);
std
::
string
buffer
(
1024
,
'c'
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
writer
.
write
(
buffer
);
}
}
/**
* Delete everything with id>99, C style
*/
void
TearDown
()
override
{
// delete files
fs
::
remove
(
test_upload_file_1
);
fs
::
remove
(
test_download_file_1
);
caosdb_connection_connection
connection
;
caosdb_connection_connection_manager_get_default_connection
(
&
connection
);
...
...
@@ -581,3 +603,55 @@ TEST_F(test_ccaosdb, test_insert_with_prop_and_parent) {
caosdb_transaction_delete_transaction
(
&
prop_insertion
);
caosdb_entity_delete_entity
(
&
original_prop
);
}
TEST_F
(
test_ccaosdb
,
test_up_n_download_file
)
{
caosdb_connection_connection
connection
;
caosdb_connection_connection_manager_get_default_connection
(
&
connection
);
caosdb_entity_entity
original_entity
;
caosdb_entity_create_entity
(
&
original_entity
);
caosdb_entity_entity_set_role
(
&
original_entity
,
"FILE"
);
caosdb_entity_entity_set_local_path
(
&
original_entity
,
test_upload_file_1
.
c_str
());
caosdb_entity_entity_set_file_path
(
&
original_entity
,
"/some/file"
);
caosdb_transaction_transaction
insert_transaction
;
caosdb_connection_connection_create_transaction
(
&
connection
,
&
insert_transaction
);
caosdb_transaction_transaction_insert_entity
(
&
insert_transaction
,
&
original_entity
);
int
return_code
(
caosdb_transaction_transaction_execute
(
&
insert_transaction
));
EXPECT_EQ
(
return_code
,
0
);
caosdb_transaction_result_set
rec_results
;
caosdb_transaction_transaction_get_result_set
(
&
insert_transaction
,
&
rec_results
);
caosdb_entity_entity
inserted_rec
;
caosdb_transaction_result_set_at
(
&
rec_results
,
&
inserted_rec
,
0
);
char
*
rec_id
=
nullptr
;
// NOLINT
caosdb_entity_entity_get_id
(
&
inserted_rec
,
&
rec_id
);
caosdb_entity_entity
download_entity
;
caosdb_entity_create_entity
(
&
download_entity
);
caosdb_entity_entity_set_role
(
&
download_entity
,
"FILE"
);
caosdb_entity_entity_set_local_path
(
&
download_entity
,
"lol"
);
caosdb_entity_entity_set_file_path
(
&
download_entity
,
"/some/file"
);
caosdb_transaction_transaction
retrieve_transaction_1
;
caosdb_connection_connection_create_transaction
(
&
connection
,
&
retrieve_transaction_1
);
EXPECT_EQ
(
return_code
,
0
);
// return_code = caosdb_transaction_transaction_retrieve_by_id(
// &retrieve_transaction_1, rec_id);
return_code
=
caosdb_transaction_transaction_retrieve_and_download_file_by_id
(
&
retrieve_transaction_1
,
rec_id
,
test_download_file_1
.
c_str
());
EXPECT_EQ
(
return_code
,
caosdb
::
StatusCode
::
GO_ON
);
return_code
=
caosdb_transaction_transaction_execute
(
&
retrieve_transaction_1
);
EXPECT_EQ
(
return_code
,
0
);
caosdb_transaction_result_set
result_set
;
return_code
=
caosdb_transaction_transaction_get_result_set
(
&
retrieve_transaction_1
,
&
result_set
);
EXPECT_EQ
(
return_code
,
0
);
}
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