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

Add test fore core plugin and make it a PR to test actions on prs

This commit is contained in:
Ryan Voots 2020-10-30 11:25:26 -07:00
parent bd2f4948b9
commit a23c30227f
2 changed files with 45 additions and 0 deletions

View file

@ -29,10 +29,12 @@ sub {
if ( Module::CoreList->can('deprecated_in') ) {
my $dep = Module::CoreList->deprecated_in($module);
print " and deprecated in $dep" if $dep;
return 'handled';
}
if ( Module::CoreList->can('removed_from') ) {
my $rem = Module::CoreList->removed_from($module);
print " and removed from $rem" if $rem;
return 'handled';
}
}
else {
@ -42,10 +44,12 @@ sub {
print 'Found', scalar @modules, ':', join ',',
map { $_ . ' in ' . Module::CoreList->first_release($_) }
@modules;
return 'handled';
}
else {
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();