1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 18:35:49 -04:00

Merge pull request #24 from perlbot/test-pr-run

Add test for core plugin and make it a PR to test actions on prs
This commit is contained in:
Ryan Voots 2020-10-30 14:29:10 -07:00 committed by GitHub
commit eaebbef9f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 2 deletions

View file

@ -45,8 +45,6 @@ requires "Net::DNS";
requires "Net::INET6Glue::INET_is_INET6"; requires "Net::INET6Glue::INET_is_INET6";
requires "Parse::RecDescent"; requires "Parse::RecDescent";
requires "Path::Tiny"; requires "Path::Tiny";
requires "Paws";
requires "Paws::Credential::Explicit";
requires "POE"; requires "POE";
requires "POE::Component::IRC"; requires "POE::Component::IRC";
requires "POE::Component::IRC::Common"; requires "POE::Component::IRC::Common";

View file

@ -29,10 +29,12 @@ sub {
if ( Module::CoreList->can('deprecated_in') ) { if ( Module::CoreList->can('deprecated_in') ) {
my $dep = Module::CoreList->deprecated_in($module); my $dep = Module::CoreList->deprecated_in($module);
print " and deprecated in $dep" if $dep; print " and deprecated in $dep" if $dep;
return 'handled';
} }
if ( Module::CoreList->can('removed_from') ) { if ( Module::CoreList->can('removed_from') ) {
my $rem = Module::CoreList->removed_from($module); my $rem = Module::CoreList->removed_from($module);
print " and removed from $rem" if $rem; print " and removed from $rem" if $rem;
return 'handled';
} }
} }
else { else {
@ -42,10 +44,12 @@ sub {
print 'Found', scalar @modules, ':', join ',', print 'Found', scalar @modules, ':', join ',',
map { $_ . ' in ' . Module::CoreList->first_release($_) } map { $_ . ' in ' . Module::CoreList->first_release($_) }
@modules; @modules;
return 'handled';
} }
else { else {
print "Module $module does not appear to be in core. Perhaps capitalization matters or try using the 'cpan' command to search for it."; print "Module $module does not appear to be in core. Perhaps capitalization matters or try using the 'cpan' command to search for it.";
return 'handled';
} }
} }
} }

41
t/core-plugin.t Normal file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Test::More;
use Test::Differences qw/ eq_or_diff /;
use Capture::Tiny qw/capture/;
use lib '.';
my $sub = require plugins::core;
sub make_said
{
my ($body, $who, $server, $channel) = @_;
my @args = split /\s+/, $body;
my $said = {
body => $body,
recommended_args => \@args,
};
}
sub check
{
local $Test::Builder::Level = $Test::Builder::Level + 1;
my ( $body, $want, $res, $blurb ) = @_;
my $said = make_said($body);
my ($out, $err, @result) = capture {
$sub->( $said );
};
return eq_or_diff( $err, "", "no errors" )
&& eq_or_diff(\@result, $res, "Result is correct")
&& eq_or_diff( $out, $want, $blurb );
}
check("", "usage: core Module::Here", ["handled"], "usage help");
check("CGI", "CGI Added to perl core as of 5.004 and deprecated in 5.019007", ["handled"], "deprecated");
check("Data::Dumper", "Data::Dumper Added to perl core as of 5.005", ["handled"], "never gonna give it up");
done_testing();