X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fgit-codeowners;a=blobdiff_plain;f=t%2Ffile-codeowners.t;h=7bfb53ca9636eb48e812f137b0e435bf1b18ad7b;hp=a50a050eb8dbebb859297879100481c7a72e80e8;hb=6568d5ded4f54ec5ff663b0196f10488910145b4;hpb=bbf4da1268e0c9c58f9ed28fadc499fc40a0f03e diff --git a/t/file-codeowners.t b/t/file-codeowners.t index a50a050..7bfb53c 100644 --- a/t/file-codeowners.t +++ b/t/file-codeowners.t @@ -94,6 +94,30 @@ subtest 'parse errors', sub { like($@, qr/^Parse error on line 1/, 'parse error'); }; +subtest 'handling projects', sub { + my $file = File::Codeowners->parse("$Bin/samples/kitchensink.CODEOWNERS"); + my $r; + + is_deeply($r = $file->projects, [ + 'Transportation', + ], 'projects listed') or diag explain $r; + + $file->rename_project('Transportation', 'Getting Around'); + is_deeply($r = $file->projects, [ + 'Getting Around', + ], 'project renamed') or diag explain $r; + + is_deeply($r = [@{$file->_lines}[-3 .. -1]], [ + {comment => ' Project: Getting Around', project => 'Getting Around'}, + {}, + {pattern => '/vehicles/**/batmobile.cad', 'owners' => ['@"Lucius Fox"'], project => 'Getting Around'}, + ], 'renaming project properly modifies lines') or diag explain $r; + + $file->update_owners_by_project('Getting Around', '@twoface'); + ok( scalar grep { $_ eq '@twoface' } @{$file->owners}, 'updating owner adds new owner'); + ok(!scalar grep { $_ eq '@"Lucius Fox"' } @{$file->owners}, 'updating owner removes old owner'); +}; + subtest 'editing and writing files', sub { my $file = File::Codeowners->parse("$Bin/samples/basic.CODEOWNERS"); my $r;