]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | use Data::Dumper qw/Dumper/; | |
6 | use Test::RequiresInternet qw/getstrike.net 443/; | |
7 | use Test::More tests => 11; | |
8 | use Try::Tiny; | |
9 | BEGIN { use_ok('WebService::Strike') }; | |
10 | ||
11 | my ($t1, $t2, $t3); | |
12 | try { | |
13 | ($t1, $t2, $t3) = strike qw/B425907E5755031BDA4A8D1B6DCCACA97DA14C04 5D4FD5A64E436A831383773F85FB38B888B9ECC9 85DF191A921C20B2DDAFF72368CAB93BA18C5ACE/; | |
14 | } catch { | |
15 | diag 'Error while calling strike:', "\n", Dumper $_ | |
16 | }; | |
17 | ||
18 | subtest 'order' => sub { | |
19 | plan tests => 3; | |
20 | is $t1->hash, 'B425907E5755031BDA4A8D1B6DCCACA97DA14C04', 'hash #1'; | |
21 | is $t2->hash, '5D4FD5A64E436A831383773F85FB38B888B9ECC9', 'hash #2'; | |
22 | is $t3->hash, '85DF191A921C20B2DDAFF72368CAB93BA18C5ACE', 'hash #3' | |
23 | }; | |
24 | ||
25 | is $t1->date, 1420502400, 'date'; | |
26 | is $t2->title, 'FreeBSD 7.1 i386.DVD.iso', 'title'; | |
27 | like $t1->torrent, qr/^d/, 'torrent file starts with d'; | |
28 | like $t1->description, qr#GNU/Linux#, 'description contains GNU/Linux'; | |
29 | ||
30 | try { | |
31 | strike 'aaa'; | |
32 | } catch { | |
33 | is $_->{status}, 404, 'non-existent torrent status is 404'; | |
34 | }; | |
35 | ||
36 | my @debian = strike_search 'Debian'; | |
37 | ok @debian > 10, 'search for Debian returned more than 10 results'; | |
38 | try { | |
39 | strike_search "nosuchstring$$"; | |
40 | } catch { | |
41 | is $_->{status}, 404, "search for nosuchstring$$ returned 404" | |
42 | }; | |
43 | ||
44 | my $p = strike_search 'Perl', 1; | |
45 | is @{$p->file_names}, $p->count, 'file_names has count elements'; | |
46 | ||
47 | my $imdb = strike('ED70C185E3E3246F30B2FDB08D504EABED5EEA3F')->imdb; | |
48 | is $imdb->{title}, 'The Walking Dead', 'imdb title'; |