App-ReportPrereqs

 view release on metacpan or  search on metacpan

xt/arguments.t  view on Meta::CPAN

use Capture::Tiny qw(capture);

use Test::More 0.88;

use lib qw(.);

require_ok('bin/report-prereqs') or BAIL_OUT();

note('invalid parameter');
{
    local @ARGV = ('--no-such-option');

    my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
    is( $result[0], 2, '_main() returns 2' );
    ok( scalar @result == 1, '... and nothing else' );
    is( $stdout, q{}, '... prints nothing to STDOUT' );
    like( $stderr, qr{\Qusage: arguments.t\E}, '... prints usage to STDERR' );
}

note('to many arguments');
{
    local @ARGV = qw(hello world);

    my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
    is( $result[0], 2, '_main() returns 2' );
    ok( scalar @result == 1, '... and nothing else' );
    is( $stdout, q{}, '... prints nothing to STDOUT' );
    like( $stderr, qr{\Qusage: arguments.t\E}, '... prints usage to STDERR' );
}

note('--meta and --cpanfile');
{
    local @ARGV = qw(--meta META.json --cpanfile cpanfile);

    my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
    is( $result[0], 2, '_main() returns 2' );
    ok( scalar @result == 1, '... and nothing else' );
    is( $stdout, q{}, '... prints nothing to STDOUT' );
    like( $stderr, qr{\Qusage: arguments.t\E}, '... prints usage to STDERR' );
}

note('--meta and url');
{
    local @ARGV = qw(--meta META.json http://example.com);

    my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
    is( $result[0], 2, '_main() returns 2' );
    ok( scalar @result == 1, '... and nothing else' );
    is( $stdout, q{}, '... prints nothing to STDOUT' );
    like( $stderr, qr{\Qusage: arguments.t\E}, '... prints usage to STDERR' );
}

note('--cpanfile and url');
{
    local @ARGV = qw(--cpanfile cpanfile http://example.com);

    my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
    is( $result[0], 2, '_main() returns 2' );
    ok( scalar @result == 1, '... and nothing else' );
    is( $stdout, q{}, '... prints nothing to STDOUT' );
    like( $stderr, qr{\Qusage: arguments.t\E}, '... prints usage to STDERR' );
}

#
done_testing();

xt/complicated-file.t  view on Meta::CPAN

      )
    {
        my $filename = shift @{$i};

        note("complicated $filename file");

        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        {

            local @ARGV = @{$i};

            my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
            is( $result[0], undef, '_main() returns undef' );
            ok( scalar @result == 0, '... and nothing else' );

            my @expected = (
                "Versions for all modules listed in $filename:",
                q{},
                q{=== Configure Requires ===},
                q{},

xt/four-modules.t  view on Meta::CPAN

        [ 'cpanfile',  File::Spec->catdir( 'corpus', 'dist5' ), ],
        [ 'META.json', File::Spec->catdir( q{..},    'dist6' ), qw(--meta), ],
        [ 'META.yml',  File::Spec->catdir( q{..},    'dist7' ), qw(--meta META.yml), ],
      )
    {
        my $filename = shift @{$i};

        note("4 modules in $filename (2 don't exist)");
        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], undef, '_main() returns undef' );
        ok( scalar @result == 0, '... and nothing else' );

        my @expected = (
            "Versions for all modules listed in $filename:",
            q{},
            q{=== Runtime Requires ===},
            q{},

xt/invalid-file.t  view on Meta::CPAN

        [ 'cpanfile',  File::Spec->catdir( 'corpus', 'dist2' ), ],
        [ 'META.json', File::Spec->catdir( q{..},    'dist3' ), qw(--meta META.json), ],
        [ 'META.yml',  File::Spec->catdir( q{..},    'dist4' ), qw(--meta META.yml), ],
      )
    {

        my $filename = shift @{$i};
        note("invalid $filename");
        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], 1, '_main() returns 1' );
        ok( scalar @result == 1, '... and nothing else' );
        is( $stdout, q{}, '... prints nothing to STDOUT' );
        ok( length($stderr), q{... prints an error to STDERR (error is from Module::CPANfile/CPAN::Meta, we don't test what the error is)} );
    }
}

#

xt/invalid-version.t  view on Meta::CPAN

        [ 'META.json', File::Spec->catdir( q{..},    'dist9' ), qw(--meta), ],
        [ 'META.yml',  File::Spec->catdir( q{..},    'dist2' ), qw(--meta META.yml), ],
      )
    {
        my $filename = shift @{$i};

        note("Local::Psi in $filename (invalid version in module)");

        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], undef, '_main() returns undef' );
        ok( scalar @result == 0, '... and nothing else' );

        my @expected = (
            "Versions for all modules listed in $filename:",
            q{},
            q{=== Runtime Requires ===},
            q{},

xt/no-file.t  view on Meta::CPAN

    chdir File::Spec->catdir( 'corpus', 'dist1' ) or skip "Test setup failed: Cannot chdir: $!";

    for my $i (
        [ 'no cpanfile', ],
        [ 'no META.json (--meta)',         qw(--meta) ],
        [ 'no META.yml (--meta META.yml)', qw(--meta META.yml) ],
      )
    {
        note( shift @{$i} );

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], 1, '_main() returns 1' );
        ok( scalar @result == 1, '... and nothing else' );
        is( $stdout, q{}, '... prints nothing to STDOUT' );
        ok( length($stderr), q{... prints an error to STDERR (error is from Module::CPANfile/CPAN::Meta, we don't test what the error is)} );
    }
}

#

xt/no-version.t  view on Meta::CPAN

        [ 'META.json', File::Spec->catdir( q{..},    'dist8' ), qw(--meta), ],
        [ 'META.yml',  File::Spec->catdir( q{..},    'dist9' ), qw(--meta META.yml), ],
      )
    {
        my $filename = shift @{$i};

        note("Local::Omega in $filename (no version in module)");

        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], undef, '_main() returns undef' );
        ok( scalar @result == 0, '... and nothing else' );

        my @expected = (
            "Versions for all modules listed in $filename:",
            q{},
            q{=== Runtime Requires ===},
            q{},

xt/one-invalid-module.t  view on Meta::CPAN

        [ 'META.json', File::Spec->catdir( q{..},    'dist5' ), qw(--meta), ],
        [ 'META.yml',  File::Spec->catdir( q{..},    'dist6' ), qw(--meta META.yml), ],
      )
    {
        my $filename = shift @{$i};

        note("only Local::Alpha::DoesNotExist in $filename");

        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], undef, '_main() returns undef' );
        ok( scalar @result == 0, '... and nothing else' );

        my @expected = (
            "Versions for all modules listed in $filename:",
            q{},
            q{=== Runtime Requires ===},
            q{},

xt/one-valid-module.t  view on Meta::CPAN

        [ 'META.json', File::Spec->catdir( q{..},    'dist4' ), qw(--meta), ],
        [ 'META.yml',  File::Spec->catdir( q{..},    'dist5' ), qw(--meta META.yml), ],
      )
    {
        my $filename = shift @{$i};

        note("only Local::Alpha in $filename");

        chdir shift @{$i} or skip "Test setup failed: Cannot chdir: $!";

        local @ARGV = @{$i};

        my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
        is( $result[0], undef, '_main() returns undef' );
        ok( scalar @result == 0, '... and nothing else' );

        my @expected = (
            "Versions for all modules listed in $filename:",
            q{},
            q{=== Runtime Requires ===},
            q{},

xt/url.t  view on Meta::CPAN

        },
        'content' => "Could not connect to 'no.such.url:80': node name or service name not known\n",
        'url'     => 'http://no.such.url./cpanfile',
        'reason'  => 'Internal Exception',
        'status'  => 599,
    };

    my $module = Test::MockModule->new('HTTP::Tiny');
    $module->redefine( 'get', sub { return $res; } );

    local @ARGV = ('http://no.such.url/cpanfile');

    my ( $stdout, $stderr, @result ) = capture { App::ReportPrereqs::_main() };
    is( $result[0], 1, '_main() returns 1' );
    ok( scalar @result == 1, '... and nothing else' );
    is( $stdout, q{},             '... prints nothing to STDOUT' );
    is( $stderr, $res->{content}, '... prints the error message from HTTP::Tiny' );
}

note(q{download file from valid url});
SKIP:

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.139 second using v1.00-cache-2.02-grep-82fe00e-cpan-da92000dfeb )