> On 十二月 2, 2016, 10:17 p.m., Benjamin Mahler wrote:
> > src/tests/master_validation_tests.cpp, lines 2371-2380
> > <https://reviews.apache.org/r/54300/diff/1/?file=1574589#file1574589line2371>
> >
> > How about splitting each case with a block? As it stands its a bit hard
> > to read what each case is doing without the comments. For example:
> >
> > ```
> > // Not MULTI_ROLE, no 'role' (defuaults to "*"), no 'roles'.
> > {
> > FrameworkInfo frameworkInfo;
> > EXPECT_NONE(framework::internal::validateRoles(frameworkInfo));
> > }
> >
> > // Not MULTI_ROLE, 'role' set, no 'roles'.
> > {
> > FrameworkInfo frameworkInfo;
> > frameworkInfo.set_role("foo");
> > EXPECT_NONE(framework::internal::validateRoles(frameworkInfo));
> > }
> >
> > // MULTI_ROLE, 'role' set (error!), no 'roles'.
> > {
> > ...
> > }
> >
> > ...
> > ```
This may cause some duplicate code, the current test is reusing some code as
following:
```
FrameworkInfo frameworkInfo1;
EXPECT_NONE(::framework::internal::validateRoles(frameworkInfo1));
frameworkInfo1.set_role("foo");
EXPECT_NONE(::framework::internal::validateRoles(frameworkInfo1));
frameworkInfo1.add_capabilities()->set_type(
FrameworkInfo::Capability::MULTI_ROLE);
// 'Role' is set, but MULTI_ROLE capability is also enabled.
EXPECT_SOME(::framework::internal::validateRoles(frameworkInfo1));
frameworkInfo1.add_roles("bar");
frameworkInfo1.add_roles("qux");
// All 'role', 'roles' and MULTI_ROLE are set.
EXPECT_SOME(::framework::internal::validateRoles(frameworkInfo1));
```
`frameworkInfo1` is used by three test cases, how about put those three cases
into a block and add comments for each test cases?
```
{
// Not MULTI_ROLE, no 'role' (defuaults to "*"), no 'roles'.
FrameworkInfo frameworkInfo1;
EXPECT_NONE(::framework::internal::validateRoles(frameworkInfo1));
// Not MULTI_ROLE, 'role' set, no 'roles'.
frameworkInfo1.set_role("foo");
EXPECT_NONE(::framework::internal::validateRoles(frameworkInfo1));
// 'Role' is set, but MULTI_ROLE capability is also enabled.
frameworkInfo1.add_capabilities()->set_type(
FrameworkInfo::Capability::MULTI_ROLE);
EXPECT_SOME(::framework::internal::validateRoles(frameworkInfo1));
// All 'role', 'roles' and MULTI_ROLE are set.
frameworkInfo1.add_roles("bar");
frameworkInfo1.add_roles("qux");
EXPECT_SOME(::framework::internal::validateRoles(frameworkInfo1));
}
{
...
}
```
- Guangya
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/54300/#review157842
-----------------------------------------------------------
On 十二月 2, 2016, 8:51 a.m., Jay Guo wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/54300/
> -----------------------------------------------------------
>
> (Updated 十二月 2, 2016, 8:51 a.m.)
>
>
> Review request for mesos, Benjamin Mahler and Guangya Liu.
>
>
> Bugs: MESOS-6629
> https://issues.apache.org/jira/browse/MESOS-6629
>
>
> Repository: mesos
>
>
> Description
> -------
>
> There are three attributes: 'role', 'roles' and MULTI_ROLE to be
> validated by this method, therefore covered by 2^3 test cases.
> Also the test ensures this method checks duplicate entries in 'roles'.
>
>
> Diffs
> -----
>
> src/tests/master_validation_tests.cpp
> 5c44967a077551944831383a6bcc6dcb1c626df9
>
> Diff: https://reviews.apache.org/r/54300/diff/
>
>
> Testing
> -------
>
>
> Thanks,
>
> Jay Guo
>
>