@@ -16,26 +16,26 @@ local $SIG{__WARN__} = sub {};
1616describe " class `$CLASS `" => sub {
1717 my %config = (
1818 codeowners => CODEOWNERS_FILE,
19- owner => ' @teams/alpha' ,
20- excludes => [' .gitlab-ci.yml' ]
19+ owner => ' @teams/alpha' ,
20+ excludes => [ ' .gitlab-ci.yml' ]
2121 );
2222
2323 tests ' it can be instantiated' => sub {
2424 can_ok($CLASS , ' new' );
2525 };
2626
2727 tests " codeowners file not found" => sub {
28- ok(dies{$CLASS -> new((codeowners => ' foo.php' , owner => ' @teams/alpha' ))}, ' died with codeowners not found' ) or note ($@ );
28+ ok(dies {$CLASS -> new((codeowners => ' foo.php' , owner => ' @teams/alpha' ))}, ' died with codeowners not found' ) or note($@ );
2929 };
3030
3131 tests " mandatory config options" => sub {
32- ok(dies{$CLASS -> new((owner => ' @teams/alpha' ))}, ' died with missing codeowners option' ) or note ($@ );
33- ok(dies{$CLASS -> new((codeowners => CODEOWNERS_FILE))}, ' died with missing owner option' ) or note ($@ );
34- ok(lives{$CLASS -> new((owner => ' @teams/alpha' , codeowners => CODEOWNERS_FILE))}, ' lived with mandatory options' ) or note ($@ );
32+ ok(dies {$CLASS -> new((owner => ' @teams/alpha' ))}, ' died with missing codeowners option' ) or note($@ );
33+ ok(dies {$CLASS -> new((codeowners => CODEOWNERS_FILE))}, ' died with missing owner option' ) or note($@ );
34+ ok(lives {$CLASS -> new((owner => ' @teams/alpha' , codeowners => CODEOWNERS_FILE))}, ' lived with mandatory options' ) or note($@ );
3535 };
3636
3737 tests ' owner with blacklist and exclude' => sub {
38- my ($object , $exception , $warnings , @excludes );
38+ my ($object , $exception , $warnings );
3939
4040 $exception = dies {
4141 $warnings = warns {
@@ -46,12 +46,12 @@ describe "class `$CLASS`" => sub {
4646 is($exception , undef , ' no exception thrown' );
4747 is($warnings , 0, ' no warnings generated' );
4848
49- is($object -> {blacklist }{' @teams/alpha' }, [' /src/Command/Config/ConfigPhraseKeyCommand.php' ], ' blacklist correct' );
49+ is($object -> {blacklist }{' @teams/alpha' }, [ ' /src/Command/Config/ConfigPhraseKeyCommand.php' ], ' blacklist correct' ) or diag Dumper( $object );
5050 is(' .gitlab-ci.yml' , not_in_set(@{$object -> {codeowners }{' @teams/alpha' }}), ' excluded file not defined' );
5151 };
5252
5353 tests ' module methods' => sub {
54- my ($object , $exception , $warnings , @excludes );
54+ my ($object , $exception , $warnings );
5555
5656 $exception = dies {
5757 $warnings = warns {
@@ -68,15 +68,15 @@ describe "class `$CLASS`" => sub {
6868 item ' /src/Service/' ;
6969 end;
7070 },
71- ' GetPaths call correct'
71+ ' GetPaths call correct'
7272 );
7373
7474 is($object -> getBlacklistPaths(),
7575 array {
7676 item ' /src/Command/Config/ConfigPhraseKeyCommand.php' ;
7777 end;
7878 },
79- ' GetBlacklistPaths call correct'
79+ ' GetBlacklistPaths call correct'
8080 );
8181
8282 is($object -> getCommaSeparatedPathList(), ' /src/Command/,/src/Service/' , ' GetCommaSeparatedPathList call correct' );
@@ -85,12 +85,12 @@ describe "class `$CLASS`" => sub {
8585
8686 is($object -> intersectCommaSeparatedPathList(@arr ), ' /src/Command/' , ' IntersectToCommaSeparatedPathList call correct' );
8787
88- is([$object -> intersect(@arr )],
88+ is([ $object -> intersect(@arr ) ],
8989 array {
9090 item ' /src/Command/' ;
9191 end;
9292 },
93- ' Intersect call correct'
93+ ' Intersect call correct'
9494 );
9595
9696 is($object -> match(' /src/Service/' ), 1, ' Match call match correct' );
@@ -101,5 +101,42 @@ describe "class `$CLASS`" => sub {
101101 };
102102};
103103
104+ describe ' test codeowners syntax' => sub {
105+ my ($object , %config , $owner , $expected_paths , $exception , $warnings );
106+
107+ case ' section with default owner' => sub {
108+ $owner = ' @teams/beta' ;
109+ $expected_paths = [ ' /src/Command/Config/ConfigPhraseKeyCommand.php' , ' /src/DependencyInjection/' ];
110+ };
111+
112+ case ' optional section with default owner and required approvals' => sub {
113+ $owner = ' @teams/gamma' ;
114+ $expected_paths = [ ' /tests/Unit/Service/' ];
115+ };
116+
117+ case ' owner with email' => sub {
118+ 119+ $expected_paths = [ ' /src/Service/' ];
120+ };
121+
122+ tests ' module get paths' => sub {
123+ %config = (
124+ codeowners => CODEOWNERS_FILE,
125+ owner => $owner ,
126+ excludes => [ ' .gitlab-ci.yml' ]
127+ );
128+
129+ $exception = dies {
130+ $warnings = warns {
131+ $object = $CLASS -> new(%config );
132+ };
133+ };
134+
135+ is($exception , undef , ' no exception thrown' );
136+ is($warnings , 0, ' no warnings generated' );
137+ is($object -> getPaths(), $expected_paths , ' paths correct' ) or diag Dumper($object );
138+ };
139+ };
140+
104141done_testing();
105142
0 commit comments