-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathsearch_web.t
42 lines (34 loc) · 1.2 KB
/
search_web.t
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
use strict;
use warnings;
use lib 't/lib';
# USE `bin/prove_live` to run this
# READ the README.txt in this dir
use MetaCPAN::Query::Search ();
use MetaCPAN::TestServer ();
use Test::More;
# Just use this to get an es object.
my $server = MetaCPAN::TestServer->new;
my $search = MetaCPAN::Query::Search->new( es => $server->es_client );
my %tests = (
'anyevent http' => 'AnyEvent::HTTP',
'anyevent' => 'AnyEvent',
'AnyEvent' => 'AnyEvent',
'dbi' => 'DBI',
'dbix class resultset' => 'DBIx::Class::ResultSet',
'DBIx::Class' => 'DBIx::Class',
'Dist::Zilla' => 'Dist::Zilla',
'HTML::Element' => 'HTML::Element',
'HTML::TokeParser' => 'HTML::TokeParser',
'net dns' => 'Net::DNS',
'net::amazon::s3' => 'Net::Amazon::S3',
'Perl::Critic' => 'Perl::Critic',
);
for my $q ( sort keys %tests ) {
my $match = $tests{$q};
my $returned = $search->search_web($q);
my $first_match = $returned->{results}->[0]->[0];
is( $first_match->{documentation},
$match, "Search for ${q} matched ${match}" );
# or diag Dumper($first_match);
}
done_testing();