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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#!perl
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Ref::Util qw< is_arrayref >;
use lib '.';
use t::lib::Functions;
my $mc = mcpan();
can_ok( $mc, 'author' );
my $author = $mc->author('XSAWYERX');
isa_ok( $author, 'MetaCPAN::Client::Author' );
can_ok( $author, 'pauseid' );
is( $author->pauseid, 'XSAWYERX', 'Correct author' );
my $most_daves;
{
my $daves = $mc->author( {
either => [
{ name => 'Dave *' },
{ name => 'David *' },
]
} );
isa_ok( $daves, 'MetaCPAN::Client::ResultSet' );
can_ok( $daves, 'total' );
ok( $daves->total > 200, 'Lots of Daves' );
$most_daves = $daves->total;
}
{
my $daves = $mc->author( {
either => [
{ name => 'Dave *' },
{ name => 'David *' },
],
not => [
{ name => 'Dave S*' },
{ name => 'David S*' },
],
} );
isa_ok( $daves, 'MetaCPAN::Client::ResultSet' );
can_ok( $daves, 'total' );
ok( $daves->total < $most_daves, 'Definitely less Daves' );
}
{
my $daves = $mc->author( {
either => [
{
all => [
{ name => 'Dave *' },
{ email => '*gmail.com' },
],
},
{
all => [
{ name => 'David *' },
{ email => '*gmail.com' },
],
},
]
} );
isa_ok( $daves, 'MetaCPAN::Client::ResultSet' );
can_ok( $daves, 'total' );
ok( $daves->total <= $most_daves, 'Definitely not more Daves' );
while ( my $dave = $daves->next ) {
my @emails = is_arrayref $dave->email ? @{ $dave->email } : $dave->email;
ok(
grep( +( $_ =~ /gmail\.com$/ ), @emails ),
'This Dave has a Gmail account',
);
}
}
my $johns = $mc->author( {
all => [
{ name => 'John *' },
{ email => '*gmail.com' },
]
} );
isa_ok( $johns, 'MetaCPAN::Client::ResultSet' );
can_ok( $johns, 'total' );
ok( $johns->total > 0, 'Got some Johns' );
while ( my $john = $johns->next ) {
my @emails = is_arrayref $john->email ? @{ $john->email } : $john->email;
ok(
grep( +( $_ =~ /gmail\.com$/ ), @emails ),
'This John has a Gmail account',
);
}
done_testing;
|