/
02_fails.t
48 lines (40 loc) · 1.11 KB
/
02_fails.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
43
44
45
46
47
#!perl
use warnings;
use strict;
use Test::Exception;
use lib qw(t/lib);
use Mock::LWP::UserAgent;
use Net::Topsy;
use Test::More;
use Test::Warn;
my @api_search_methods = qw/experts search searchcount searchdate searchhistogram/;
my @api_url_methods = qw/authorinfo linkposts linkpostcount populartrackbacks stats tags trackbacks urlinfo/;
my @link_methods = qw/top trending/;
my $nt = Net::Topsy->new( key => 'foo' );
throws_ok( sub { my $nt = Net::Topsy->new( key => undef ) },
qr/Attribute \(key\) does not pass the type constraint/,
);
for my $method (@api_search_methods) {
throws_ok( sub {
$nt->$method( { } );
},
qr/$method -> required params missing: q/,
);
}
for my $method (@api_url_methods) {
throws_ok( sub {
$nt->$method( { } );
},
qr/$method -> required params missing: url/,
);
}
done_testing;
exit;
# does Topsy not warn about unexpected params anymore?
for my $method (@link_methods) {
warnings_like( sub {
$nt->$method( { thresh => 'top100', q => 'foo' } );
},
qr/unexpected params: q/,
);
}