Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
445
Issues
445
List
Boards
Labels
Service Desk
Milestones
Merge Requests
71
Merge Requests
71
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
ac671e61
Commit
ac671e61
authored
Feb 24, 2017
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[5107] Two unit-tests implemented for CtrlAgentCommandMgr
parent
26080835
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
6 deletions
+45
-6
src/bin/agent/ctrl_agent_command_mgr.h
src/bin/agent/ctrl_agent_command_mgr.h
+1
-3
src/bin/agent/tests/ctrl_agent_command_mgr_unittest.cc
src/bin/agent/tests/ctrl_agent_command_mgr_unittest.cc
+44
-3
No files found.
src/bin/agent/ctrl_agent_command_mgr.h
View file @
ac671e61
...
...
@@ -34,8 +34,6 @@ public:
/// @brief Returns sole instance of the Command Manager.
static
CtrlAgentCommandMgr
&
instance
();
private:
/// @brief Handles the command having a given name and arguments.
///
/// This method extends the base implementation with the ability to forward
...
...
@@ -54,7 +52,7 @@ private:
handleCommand
(
const
std
::
string
&
cmd_name
,
const
isc
::
data
::
ConstElementPtr
&
params
);
private:
/// @brief Private constructor.
///
/// The instance should be created using @ref CtrlAgentCommandMgr::instance,
...
...
src/bin/agent/tests/ctrl_agent_command_mgr_unittest.cc
View file @
ac671e61
...
...
@@ -6,9 +6,11 @@
#include <config.h>
#include <agent/ctrl_agent_command_mgr.h>
#include <cc/command_interpreter.h>
#include <gtest/gtest.h>
using
namespace
isc
::
agent
;
using
namespace
isc
::
data
;
namespace
{
...
...
@@ -23,16 +25,55 @@ public:
/// @brief Constructor.
///
/// Deregisters all commands except 'list-commands'.
CtrlAgentCommandMgrTest
()
{
CtrlAgentCommandMgr
::
instance
().
deregisterAll
();
CtrlAgentCommandMgrTest
()
:
mgr_
(
CtrlAgentCommandMgr
::
instance
())
{
mgr_
.
deregisterAll
();
}
/// @brief Destructor.
///
/// Deregisters all commands except 'list-commands'.
virtual
~
CtrlAgentCommandMgrTest
()
{
CtrlAgentCommandMgr
::
instance
()
.
deregisterAll
();
mgr_
.
deregisterAll
();
}
/// @brief Verifies received answer
///
/// @todo Add better checks for failure cases and for
/// verification of the response parameters.
///
/// @param answer answer to be verified
/// @param expected_code code expected to be returned in the answer
void
checkAnswer
(
ConstElementPtr
answer
,
int
expected_code
)
{
int
status_code
;
isc
::
config
::
parseAnswer
(
status_code
,
answer
);
EXPECT_EQ
(
expected_code
,
status_code
);
}
/// @brief a convenience reference to control agent command manager
CtrlAgentCommandMgr
&
mgr_
;
};
/// Just a basic test checking that non-existent command is handled
/// properly.
TEST_F
(
CtrlAgentCommandMgrTest
,
bogus
)
{
ConstElementPtr
answer
;
EXPECT_NO_THROW
(
answer
=
mgr_
.
handleCommand
(
"fish-and-chips-please"
,
ConstElementPtr
()));
checkAnswer
(
answer
,
isc
::
config
::
CONTROL_RESULT_ERROR
);
};
/// Just a basic test checking that 'list-commands' is supported.
TEST_F
(
CtrlAgentCommandMgrTest
,
listCommands
)
{
ConstElementPtr
answer
;
EXPECT_NO_THROW
(
answer
=
mgr_
.
handleCommand
(
"list-commands"
,
ConstElementPtr
()));
checkAnswer
(
answer
,
isc
::
config
::
CONTROL_RESULT_ERROR
);
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment