]> git.vpit.fr Git - perl/modules/rgit.git/blob - t/21-once.t
Test that 'rgit gui' acts as Once
[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 => 9 * 5;
10
11 use App::Rgit;
12
13 my @expected = (
14  ([ [ qw/^n ^g ^w ^b ^^/ ] ]) x 5
15 );
16
17 for my $cmd (qw/daemon gui help init version/) {
18  my ($fh, $filename) = tempfile(UNLINK => 1);
19  my $ar = 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  );
25  isnt($ar, undef, "once $cmd has a defined object");
26  my $exit = $ar->run;
27  is($exit, 0, "once $cmd returned 0");
28  my @lines = sort split /\n/, do { local $/; <$fh> };
29  is(@lines, 1, "once $cmd visited only one repo");
30  my $r = [ split /\|/, defined $lines[0] ? $lines[0] : '' ];
31  my $e = [ $cmd, qw/^n ^g ^w ^b ^^/ ];
32  is($r->[$_], $e->[$_], "once $cmd argument $_ is ok")
33   for 0 .. 5;
34 }