Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asapo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
Joao Alvim Oliveira Dias De Almeida
asapo
Commits
684b29ab
Commit
684b29ab
authored
6 years ago
by
Sergey Yakubov
Browse files
Options
Downloads
Patches
Plain Diff
fix memory leaks
parent
d690120f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
receiver/unittests/test_requests_dispatcher.cpp
+17
-15
17 additions, 15 deletions
receiver/unittests/test_requests_dispatcher.cpp
with
17 additions
and
15 deletions
receiver/unittests/test_requests_dispatcher.cpp
+
17
−
15
View file @
684b29ab
...
...
@@ -48,13 +48,13 @@ using asapo::MockStatistics;
using
asapo
::
RequestsDispatcher
;
using
asapo
::
Statistics
;
namespace
{
TEST
(
RequestDispatcher
,
Constructor
)
{
a
sapo
::
Statistics
*
stat
;
RequestsDispatcher
dispatcher
{
0
,
"some_address"
,
stat
};
a
uto
stat
=
std
::
unique_ptr
<
Statistics
>
{
new
Statistics
}
;
RequestsDispatcher
dispatcher
{
0
,
"some_address"
,
stat
.
get
()
};
ASSERT_THAT
(
dynamic_cast
<
const
asapo
::
Statistics
*>
(
dispatcher
.
statistics__
),
Ne
(
nullptr
));
ASSERT_THAT
(
dynamic_cast
<
asapo
::
IO
*>
(
dispatcher
.
io__
.
get
()),
Ne
(
nullptr
));
ASSERT_THAT
(
dynamic_cast
<
asapo
::
RequestFactory
*>
(
dispatcher
.
request_factory__
.
get
()),
Ne
(
nullptr
));
...
...
@@ -109,7 +109,7 @@ class RequestsDispatcherTests : public Test {
GenericRequestHeader
header
;
MockRequest
mock_request
{
GenericRequestHeader
{},
1
};
std
::
unique_ptr
<
Request
>
request
{
&
mock_request
};
GenericNetworkResponse
response
;
void
SetUp
()
override
{
test_config
.
authorization_interval_ms
=
0
;
SetReceiverConfig
(
test_config
);
...
...
@@ -160,19 +160,19 @@ class RequestsDispatcherTests : public Test {
}
GenericNetworkResponse
MockSendR
esponse
(
bool
error
)
{
void
MockSendResponse
(
GenericNetworkResponse
*
r
esponse
,
bool
error
)
{
EXPECT_CALL
(
mock_logger
,
Debug
(
AllOf
(
HasSubstr
(
"sending response to"
),
HasSubstr
(
connected_uri
))));
GenericNetworkResponse
response
;
;
EXPECT_CALL
(
mock_io
,
Send_t
(
_
,
_
,
_
,
_
)).
WillOnce
(
DoAll
(
SetArgPointee
<
3
>
(
error
?
asapo
::
IOErrorTemplates
::
kConnectionRefused
.
Generate
().
release
()
:
nullptr
),
SaveArg1ToGenericNetworkResponse
(
&
response
),
SaveArg1ToGenericNetworkResponse
(
response
),
Return
(
0
)
));
if
(
error
)
{
EXPECT_CALL
(
mock_logger
,
Error
(
AllOf
(
HasSubstr
(
"error sending response"
),
HasSubstr
(
connected_uri
))));
}
return
response
;
return
;
}
};
...
...
@@ -210,7 +210,7 @@ TEST_F(RequestsDispatcherTests, OkCreatetNextRequest) {
TEST_F
(
RequestsDispatcherTests
,
ErrorProcessRequestErrorSend
)
{
MockHandleRequest
(
true
);
MockSendResponse
(
true
);
MockSendResponse
(
&
response
,
true
);
auto
err
=
dispatcher
->
ProcessRequest
(
request
);
...
...
@@ -220,7 +220,7 @@ TEST_F(RequestsDispatcherTests, ErrorProcessRequestErrorSend) {
TEST_F
(
RequestsDispatcherTests
,
OkProcessRequestErrorSend
)
{
MockHandleRequest
(
false
);
MockSendResponse
(
true
);
MockSendResponse
(
&
response
,
true
);
auto
err
=
dispatcher
->
ProcessRequest
(
request
);
...
...
@@ -230,7 +230,7 @@ TEST_F(RequestsDispatcherTests, OkProcessRequestErrorSend) {
TEST_F
(
RequestsDispatcherTests
,
OkProcessRequestSendOK
)
{
MockHandleRequest
(
false
);
MockSendResponse
(
false
);
MockSendResponse
(
&
response
,
false
);
auto
err
=
dispatcher
->
ProcessRequest
(
request
);
...
...
@@ -240,24 +240,26 @@ TEST_F(RequestsDispatcherTests, OkProcessRequestSendOK) {
TEST_F
(
RequestsDispatcherTests
,
ProcessRequestReturnsAlreadyExist
)
{
MockHandleRequest
(
true
,
asapo
::
IOErrorTemplates
::
kFileAlreadyExists
.
Generate
());
auto
response
=
MockSendResponse
(
false
);
MockSendResponse
(
&
response
,
false
);
auto
err
=
dispatcher
->
ProcessRequest
(
request
);
ASSERT_THAT
(
err
,
Eq
(
asapo
::
IOErrorTemplates
::
kFileAlreadyExists
));
ASSERT_THAT
(
response
.
error_code
,
Eq
(
asapo
::
kNetErrorFileIdAlreadyInUse
));
ASSERT_THAT
(
response
.
message
,
HasSubstr
(
"kFileAlreadyExists"
));
ASSERT_THAT
(
std
::
string
(
response
.
message
)
,
HasSubstr
(
std
::
string
(
"kFileAlreadyExists"
))
)
;
}
TEST_F
(
RequestsDispatcherTests
,
ProcessRequestReturnsAuthorizationFailure
)
{
MockHandleRequest
(
true
,
asapo
::
ReceiverErrorTemplates
::
kAuthorizationFailure
.
Generate
());
auto
response
=
MockSendResponse
(
false
);
MockSendResponse
(
&
response
,
false
);
auto
err
=
dispatcher
->
ProcessRequest
(
request
);
ASSERT_THAT
(
err
,
Eq
(
asapo
::
ReceiverErrorTemplates
::
kAuthorizationFailure
));
ASSERT_THAT
(
response
.
error_code
,
Eq
(
asapo
::
kNetAuthorizationError
));
ASSERT_THAT
(
response
.
message
,
HasSubstr
(
"authorization"
));
ASSERT_THAT
(
std
::
string
(
response
.
message
)
,
HasSubstr
(
"authorization"
));
}
}
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