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
|
use strict;
use warnings;
use lib 't/lib';
use Test::More;
use TestCommand;
subtest 'command: module' => sub {
my ( $stdout, $stderr, $exit ) = TestCommand->command( 'module', 'CPAN' );
like $stdout, qr/CPANSA-CPAN-2009-01/;
like $stdout, qr/CPANSA-CPAN-2020-16156/;
is $stderr, '';
isnt $exit, 0;
};
subtest 'command: module, with excluded result' => sub {
my ( $stdout, $stderr, $exit ) = TestCommand->command( 'module', 'CPAN', '--exclude' => 'CPANSA-CPAN-2009-01' );
unlike $stdout, qr/CPANSA-CPAN-2009-01/;
like $stdout, qr/CPANSA-CPAN-2020-16156/;
is $stderr, '';
isnt $exit, 0;
};
subtest 'command: module, with excluded results from file' => sub {
my $file = 't/data/excludes';
ok( -e $file, 'File that should be there is there' );
my ( $stdout, $stderr, $exit ) = TestCommand->command( 'module', 'CPAN', '--exclude-file' => $file );
unlike $stdout, qr/CPANSA-CPAN-2009-01/;
like $stdout, qr/CPANSA-CPAN-2020-16156/;
is $stderr, '';
isnt $exit, 0;
};
subtest 'command: module, with excluded results from non-existent file' => sub {
my $file = 't/data/not-there';
ok( ! -e $file, 'File that should not exist is not there' );
my ( $stdout, $stderr, $exit ) = TestCommand->command( 'module', 'CPAN', '--exclude-file' => $file );
like $stdout, qr/CPANSA-CPAN-2009-01/;
like $stdout, qr/CPANSA-CPAN-2020-16156/;
like $stderr, qr/unable to open exclude_file/;
isnt $exit, 0;
};
use Data::Dumper;
subtest 'command: unknown module' => sub {
my ( $stdout, $stderr, $exit ) = TestCommand->command( 'module', 'Unknown' );
like $stderr, qr/Module 'Unknown' is not in database/;
is $stdout, '';
isnt $exit, 0;
};
subtest 'command: invalid invocation' => sub {
my ( $stdout, $stderr, $exit ) = TestCommand->command( 'module' );
is $stdout, '';
like $stderr, qr/Error: Usage: /;
isnt $exit, 0;
};
done_testing;
|