File: command-install.t

package info (click to toggle)
perlbrew 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 752 kB
  • sloc: perl: 9,387; makefile: 7; sh: 1
file content (86 lines) | stat: -rw-r--r-- 2,622 bytes parent folder | download | duplicates (2)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env perl
use Test2::V0;
use Test2::Tools::Spec;

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test2_helpers.pl';

describe "command install" => sub {
    it "should install exact perl version" => sub {
        my $app = App::perlbrew->new(install => 'perl-5.12.1');
        my $mock = mocked($app)->expects('do_install_release')->with('perl-5.12.1', '5.12.1');
        $app->run;
        $mock->verify;
    };

    it "should install exact cperl version" => sub {
        my $app = App::perlbrew->new(install => 'cperl-5.26.4');
        my $mock = mocked($app)->expects('do_install_release')->with('cperl-5.26.4', '5.26.4');
        $app->run;
        $mock->verify;
    };

    it "should install stable version of perl" => sub {
        my @versions_sorted_from_new_to_old = qw( perl-5.29.0 perl-5.14.2 perl-5.14.1 perl-5.12.3 perl-5.12.2 );

        my $app = App::perlbrew->new(install => 'perl-stable');

        my $mock = mocked($app);
        $mock->expects('available_perls')->returns(sub { @versions_sorted_from_new_to_old });
        $mock->expects('do_install_release')->with('perl-5.14.2', '5.14.2');

        $app->run;
        $mock->verify;
    };

    it "should install blead perl" => sub {
        my $app = App::perlbrew->new(install => 'perl-blead');

        my $mock = mocked($app);
        $mock->expects('do_install_release')->never;
        $mock->expects('do_install_blead')->exactly(1)->returns(sub { "dummy" });

        $app->run;
        $mock->verify;
    };

    it "should install git checkout" => sub {
        my $checkout = tempdir (CLEANUP => 1);
        dir ($checkout, '.git')->mkpath;

        my $app = App::perlbrew->new(install => $checkout);

        my $mock = mocked($app);
        $mock->expects('do_install_git')->with($checkout)->returns(sub { "dummy" });

        $app->run;
        $mock->verify;
    };

    it "should install from archive" => sub {
        my $checkout = tempdir (CLEANUP => 1);
        my $file = file ($checkout, 'archive.tar.gz')->stringify;
        open my $fh, '>', $file;
        close $fh;

        my $app = App::perlbrew->new(install => $file);

        my $mock = mocked($app)->expects('do_install_archive')->with($file)->returns(sub { "dummy" });

        $app->run;
        $mock->verify;
    };

    it "should install from uri" => sub {
        my $app = App::perlbrew->new(install => 'http://example.com/foo/bar');

        my $mock = mocked($app)->expects('do_install_url')->with('http://example.com/foo/bar')->returns(sub { "dummy" });

        $app->run;
        $mock->verify;
    };
};

done_testing;