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
16ae5462
Verified
Commit
16ae5462
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: fix test
parent
343c4fbc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Error handling
Pipeline
#10878
failed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
conanfile.txt
+1
-1
1 addition, 1 deletion
conanfile.txt
test/test_connection.cpp
+17
-14
17 additions, 14 deletions
test/test_connection.cpp
test/test_transaction.cpp
+26
-11
26 additions, 11 deletions
test/test_transaction.cpp
with
44 additions
and
26 deletions
conanfile.txt
+
1
−
1
View file @
16ae5462
[requires]
caosdb/0.0.
5
caosdb/0.0.
6
gtest/1.11.0
[generators]
...
...
This diff is collapsed.
Click to expand it.
test/test_connection.cpp
+
17
−
14
View file @
16ae5462
...
...
@@ -18,10 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestPartR...
#include
<memory>
// for allocator, unique_ptr, __sh...
#include
<string>
// for stoi, string
#include
"boost/filesystem/path.hpp"
// for path
#include
"caosdb/authentication.h"
// for PlainPasswordAuthenticator
#include
"caosdb/certificate_provider.h"
// for PemFileCertificateProvider
...
...
@@ -32,7 +28,11 @@
#include
"caosdb/info.h"
// for VersionInfo
#include
"caosdb/utility.h"
// for get_env_var
#include
"caosdb_test_utility.h"
// for EXPECT_THROW_MESSAGE
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestPartR...
#include
"gtest/gtest_pred_impl.h"
// for Test, TestInfo, TEST, EXPEC...
#include
<memory>
// for allocator, unique_ptr, __sh...
#include
<string>
// for stoi, string
namespace
caosdb
::
connection
{
using
caosdb
::
authentication
::
PlainPasswordAuthenticator
;
...
...
@@ -57,7 +57,7 @@ TEST(test_connection, connect_somehost_42347_fails) {
auto
config
=
InsecureConnectionConfiguration
(
host
,
port
);
Connection
connection
(
config
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
ConnectionError
);
EXPECT_THROW
(
connection
.
R
et
rieve
VersionInfo
(),
ConnectionError
);
}
TEST
(
test_connection
,
connection_insecure_authentication_error_anonymous
)
{
...
...
@@ -70,7 +70,7 @@ TEST(test_connection, connection_insecure_authentication_error_anonymous) {
auto
config
=
InsecureConnectionConfiguration
(
host
,
port
);
auto
connection
=
Connection
(
config
);
EXPECT_THROW
(
connection
.
G
etVersionInfo
(),
AuthenticationError
);
EXPECT_THROW
(
connection
.
R
et
rieve
VersionInfo
(),
AuthenticationError
);
}
TEST
(
test_connection
,
connection_ssl_authentication_error_anonymous
)
{
...
...
@@ -86,8 +86,10 @@ TEST(test_connection, connection_ssl_authentication_error_anonymous) {
auto
config
=
TlsConnectionConfiguration
(
host
,
port
,
cert
);
auto
connection
=
Connection
(
config
);
EXPECT_THROW_MESSAGE
(
connection
.
GetVersionInfo
(),
AuthenticationError
,
"Please login."
);
EXPECT_THROW_MESSAGE
(
connection
.
RetrieveVersionInfo
(),
AuthenticationError
,
"The attempt to execute this transaction has not been "
"executed at all because the authentication did not "
"succeed. Original error: Please login."
);
}
TEST
(
test_connection
,
connection_ssl_authentication_error_wrong_credentials
)
{
...
...
@@ -106,8 +108,9 @@ TEST(test_connection, connection_ssl_authentication_error_wrong_credentials) {
auto
config
=
TlsConnectionConfiguration
(
host
,
port
,
cert
,
auth
);
auto
connection
=
Connection
(
config
);
EXPECT_THROW_MESSAGE
(
connection
.
GetVersionInfo
(),
AuthenticationError
,
"Authentication failed. Username or password wrong."
);
EXPECT_THROW_MESSAGE
(
connection
.
RetrieveVersionInfo
(),
AuthenticationError
,
"The attempt to execute this transaction has not been executed at all because the authentication did not succeed. Original error: Authentication failed. Username or password wrong."
);
}
TEST
(
test_connection
,
connection_ssl_authentication_success
)
{
...
...
@@ -118,10 +121,10 @@ TEST(test_connection, connection_ssl_authentication_success) {
const
auto
pre_release
=
std
::
string
(
caosdb
::
COMPATIBLE_SERVER_VERSION_PRE_RELEASE
);
auto
v_info
=
connection
->
G
etVersionInfo
();
EXPECT_EQ
(
major
,
v_info
->
GetMajor
());
EXPECT_EQ
(
minor
,
v_info
->
GetMinor
());
EXPECT_EQ
(
pre_release
,
v_info
->
GetPreRelease
());
const
auto
&
v_info
=
connection
->
R
et
rieve
VersionInfo
();
EXPECT_EQ
(
major
,
v_info
.
GetMajor
());
EXPECT_EQ
(
minor
,
v_info
.
GetMinor
());
EXPECT_EQ
(
pre_release
,
v_info
.
GetPreRelease
());
}
}
// namespace caosdb::connection
This diff is collapsed.
Click to expand it.
test/test_transaction.cpp
+
26
−
11
View file @
16ae5462
...
...
@@ -18,15 +18,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include
"caosdb/connection.h"
// for CaosDBConnection
#include
"caosdb/entity.h"
// for Entity, EntityID
#include
"caosdb/transaction.h"
// for Transaction, UniqueResult, Entity
#include
<gtest/gtest-message.h>
// for Message
#include
<gtest/gtest-test-part.h>
// for SuiteApiResolver, TestFactoryImpl
#include
"gtest/gtest_pred_impl.h"
// for Test, TestInfo, EXPECT_EQ, TEST
#include
<memory>
// for allocator, static_pointer_cast
#include
<iostream>
#include
<memory>
// for unique_ptr, allocator, __shar...
#include
"caosdb/connection.h"
// for Connection, ConnectionManager
#include
"caosdb/entity.h"
// for Entity, Messages, Message
#include
"caosdb/message_code.h"
// for ENTITY_DOES_NOT_EXIST, Messag...
#include
"caosdb/status_code.h"
// for SUCCESS, StatusCode
#include
"caosdb/transaction.h"
// for Entity, Transaction, UniqueRe...
#include
"caosdb/transaction_status.h"
// for TransactionStatus, StatusCode
#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
namespace
caosdb
::
transaction
{
using
caosdb
::
entity
::
MessageCode
;
TEST
(
test_transaction
,
DISABLED_retrieve_manufacturer_by_id
)
{
const
auto
&
connection
=
...
...
@@ -62,12 +67,22 @@ TEST(test_transaction, retrieve_non_existing) {
const
auto
*
id
=
"non-existing-id"
;
transaction
->
RetrieveById
(
id
);
transaction
->
ExecuteAsyncronously
();
transaction
->
ExecuteAsync
h
ronously
();
const
auto
&
status
=
transaction
->
WaitForIt
();
EXPECT_EQ
(
status
,
TransactionStatus
::
TRANSACTION_ERROR
);
auto
status
=
transaction
->
WaitForIt
();
EXPECT_EQ
(
status
.
GetCode
(),
TransactionStatus
::
SUCCESS
().
GetCode
());
ASSERT_EQ
(
status
.
GetCode
(),
StatusCode
::
SUCCESS
);
EXPECT_EQ
(
status
.
GetCode
(),
StatusCode
::
GENERIC_TRANSACTION_ERROR
);
const
auto
&
result_set
=
dynamic_cast
<
const
caosdb
::
transaction
::
UniqueResult
&>
(
transaction
->
GetResultSet
());
const
auto
&
entity
=
result_set
.
GetEntity
();
EXPECT_EQ
(
id
,
entity
.
GetId
());
EXPECT_TRUE
(
entity
.
HasErrors
());
ASSERT_EQ
(
entity
.
GetErrors
().
Size
(),
1
);
EXPECT_EQ
(
entity
.
GetErrors
().
At
(
0
).
GetCode
(),
MessageCode
::
ENTITY_DOES_NOT_EXIST
);
}
}
// 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