X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2Fapp-codeowners.t;h=48493d1fc2d102790e1796220250fdd0ecbbbb37;hb=refs%2Fheads%2Fdist;hp=28309d3861ca0b802cf938133128494302850377;hpb=3a345750fddc777385eacb334ea011f9327b774e;p=chaz%2Fgit-codeowners diff --git a/t/app-codeowners.t b/t/app-codeowners.t index 28309d3..48493d1 100644 --- a/t/app-codeowners.t +++ b/t/app-codeowners.t @@ -9,13 +9,13 @@ use App::Codeowners::Util qw(run_git); use App::Codeowners; use Capture::Tiny qw(capture); use File::pushd; -use Path::Tiny qw(path tempdir); +use Path::Tiny 0.089 qw(path tempdir); use Test::More; my $can_git = _can_git(); -# Set progname so that pod2usage knows how to find the script after we chdir -$0 = path($Bin)->parent->child('bin/git-codeowners')->absolute; +# Set progname so that pod2usage knows how to find the script after we chdir. +$0 = path($Bin)->parent->child('bin/git-codeowners')->absolute->stringify; $ENV{NO_COLOR} = 1; @@ -72,6 +72,25 @@ END }; }; +subtest 'create' => sub { + plan skip_all => 'Cannot run git' if !$can_git; + + my $repodir = _setup_git_repo(); + my $chdir = pushd($repodir); + + my $codeowners_filepath = path('CODEOWNERS'); + $codeowners_filepath->remove; + + my ($stdout, $stderr, $exit) = run { App::Codeowners->main(qw{create}) }; + is($exit, 0, 'exited without error'); + is($stderr, "Wrote CODEOWNERS\n", 'reportedly wrote a CODEOWNERS file'); + + ok($codeowners_filepath->is_file, 'did write CODEOWNERS file'); + + my $contents = $codeowners_filepath->slurp_utf8; + like($contents, qr/^# This file shows mappings/, 'correct contents of file') or diag $contents; +}; + done_testing; exit; @@ -95,6 +114,8 @@ a/ @snickers END run_git('-C', $repodir, qw{init})->wait; + run_git('-C', $repodir, qw{config --local user.email app-codeowners@example.com})->wait; + run_git('-C', $repodir, qw{config --local user.name App-Codeowners})->wait; run_git('-C', $repodir, qw{add .})->wait; run_git('-C', $repodir, qw{commit -m}, 'initial commit')->wait;