-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #746 from Tekki/install-cpm
Document and test install-cpm command.
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/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; | ||
|
||
no warnings 'redefine'; | ||
sub App::perlbrew::http_get { "" } | ||
|
||
throws_ok( | ||
sub { | ||
my $app = App::perlbrew->new("install-cpm"); | ||
$app->run; | ||
}, | ||
qr[ERROR: Failed to retrieve cpm executable.] | ||
); | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
use Test::Spec; | ||
use File::Temp qw( tempdir ); | ||
|
||
use App::perlbrew; | ||
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 ); | ||
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 ); | ||
|
||
{ | ||
no warnings 'redefine'; | ||
sub App::perlbrew::http_get { | ||
my ($url) = @_; | ||
like $url, qr/cpm$/, "GET cpm url: $url"; | ||
return "#!/usr/bin/env perl\n# The content of cpm"; | ||
} | ||
} | ||
|
||
describe "App::perlbrew->install_cpm" => sub { | ||
it "should produce 'cpm' in the bin dir" => sub { | ||
my $app = App::perlbrew->new("install-cpm", "-q"); | ||
$app->run(); | ||
|
||
my $cpm = App::Perlbrew::Path->new($perlbrew_root, "bin", "cpm"); | ||
ok -f $cpm, "cpm is produced. $cpm"; | ||
ok -x $cpm, "cpm should be an executable."; | ||
}; | ||
}; | ||
|
||
runtests unless caller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
use Test::Spec; | ||
use File::Temp qw( tempdir ); | ||
|
||
use App::perlbrew; | ||
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 ); | ||
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 ); | ||
|
||
{ | ||
no warnings 'redefine'; | ||
sub App::perlbrew::http_get { | ||
my ($url) = @_; | ||
like $url, qr/cpm$/, "GET cpm url: $url"; | ||
return "404 not found."; | ||
} | ||
} | ||
|
||
describe "App::perlbrew->install_cpm" => sub { | ||
it "should no produced 'cpm' in the bin dir, if the downloaded content seems to be invalid." => sub { | ||
my $error; | ||
my $error_produced = 0; | ||
eval { | ||
my $app = App::perlbrew->new("install-cpm", "-q"); | ||
$app->run(); | ||
} or do { | ||
$error = $@; | ||
$error_produced = 1; | ||
}; | ||
|
||
my $cpm = App::Perlbrew::Path->new($perlbrew_root, "bin", "cpm"); | ||
ok $error_produced, "generated an error: $error"; | ||
ok !(-f $cpm), "cpm is not produced. $cpm"; | ||
}; | ||
}; | ||
|
||
runtests unless caller; |