Added three matchers for agent tests. Added a test matcher to match the `TaskID` of `Option<TaskInfo>`, a matcher to match an `Option<TaskGroupInfo>` which contains a task with the specified `TaskID`, and a matcher to match the `TaskID` of `authorization::Request.Object.TaskInfo`.
Review: https://reviews.apache.org/r/66346/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/028ea548 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/028ea548 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/028ea548 Branch: refs/heads/master Commit: 028ea54866064762f9e044929a75b2003a5986eb Parents: 493173a Author: Meng Zhu <[email protected]> Authored: Thu Apr 5 17:44:32 2018 -0700 Committer: Greg Mann <[email protected]> Committed: Thu Apr 5 17:57:50 2018 -0700 ---------------------------------------------------------------------- src/tests/mesos.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/028ea548/src/tests/mesos.hpp ---------------------------------------------------------------------- diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp index b3b1817..3491dcd 100644 --- a/src/tests/mesos.hpp +++ b/src/tests/mesos.hpp @@ -3600,6 +3600,47 @@ MATCHER_P(TaskStatusUpdateStateEq, taskState, "") } +// This matcher is used to match the task id of +// `authorization::Request.Object.TaskInfo`. +MATCHER_P(AuthorizationRequestHasTaskID, taskId, "") +{ + if (!arg.has_object()) { + return false; + } + + if (!arg.object().has_task_info()) { + return false; + } + + return arg.object().task_info().task_id() == taskId; +} + + +// This matcher is used to match the task id of `Option<TaskInfo>`. +MATCHER_P(OptionTaskHasTaskID, taskId, "") +{ + return arg.isNone() ? false : arg->task_id() == taskId; +} + + +// This matcher is used to match an `Option<TaskGroupInfo>` which contains a +// task with the specified task id. +MATCHER_P(OptionTaskGroupHasTaskID, taskId, "") +{ + if (arg.isNone()) { + return false; + } + + foreach(const TaskInfo& taskInfo, arg->tasks()) { + if (taskInfo.task_id() == taskId) { + return true; + } + } + + return false; +} + + struct ParamExecutorType { public:
