forked from gugod/App-perlbrew
/
installation.t
59 lines (45 loc) · 1.46 KB
/
installation.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';
use Test::More;
use Test::Exception;
## main
note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";
{
my $app = App::perlbrew->new;
my @installed = grep { !$_->{is_external} } $app->installed_perls;
is 0+@installed, 0;
}
{
my $app = App::perlbrew->new("install", "perl-5.14.0");
$app->run;
my @installed = grep { !$_->{is_external} } $app->installed_perls;
is 0+@installed, 1;
is $installed[0]->{name}, "perl-5.14.0";
dies_ok {
my $app = App::perlbrew->new("install", "perl-5.14.0");
$app->run;
} "should die when doing install with existing distribution name.";
}
subtest "App::perlbrew#is_installed method." => sub {
my $app = App::perlbrew->new;
ok $app->can("is_installed");
ok $app->is_installed("perl-5.14.0");
ok !$app->is_installed("perl-5.13.0");
};
subtest "do not clobber exitsing user-specified name." => sub {
my $app = App::perlbrew->new("install", "perl-5.14.0", "--as", "the-dude");
$app->run;
my @installed = grep { !$_->{is_external} } $app->installed_perls;
is 0+@installed, 2;
ok grep { $_->{name} eq 'the-dude' } $app->installed_perls;
dies_ok {
my $app = App::perlbrew->new("install", "perl-5.14.0", "--as", "the-dude");
$app->run;
} "should die when doing install with existing user-specified name.";
};
done_testing;