]> git.vpit.fr Git - perl/modules/rgit.git/blob - t/21-once.t
Test policies
[perl/modules/rgit.git] / t / 21-once.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Cwd qw/abs_path/;
7 use File::Temp qw/tempfile/;
8
9 use Test::More tests => 8 * 4;
10
11 use App::Rgit;
12
13 my @expected = (
14  ([ [ qw/^n ^g ^w ^b ^^/ ] ]) x 4
15 );
16
17 for my $cmd (qw/version help daemon init/) {
18  my ($fh, $filename) = tempfile(UNLINK => 1);
19  my $exit = App::Rgit->new(
20   git  => abs_path('t/bin/git'),
21   root => 't',
22   cmd  => $cmd,
23   args => [ abs_path($filename), $cmd, qw/^n ^g ^w ^b ^^/ ]
24  )->run;
25  is($exit, 0, "once $cmd returned 0");
26  my @lines = sort split /\n/, do { local $/; <$fh> };
27  is(@lines, 1, "once $cmd visited only one repo");
28  my $r = [ split /\|/, defined $lines[0] ? $lines[0] : '' ];
29  my $e = [ $cmd, qw/^n ^g ^w ^b ^^/ ];
30  is($r->[$_], $e->[$_], "once $cmd argument $_ is ok")
31   for 0 .. 5;
32 }