Commit | Line | Data |
---|---|---|
27da1d36 MG |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
fceb2d41 MG |
5 | use Data::Dumper qw/Dumper/; |
6 | use Test::RequiresInternet qw/getstrike.net 443/; | |
0f6b165a | 7 | use Test::More skip_all => 'The Strike API was discontinued, therefore this test is disabled'; |
94cc52f9 | 8 | use Test::More tests => 8; |
27da1d36 MG |
9 | use Try::Tiny; |
10 | BEGIN { use_ok('WebService::Strike') }; | |
11 | ||
fceb2d41 MG |
12 | my ($t1, $t2, $t3); |
13 | try { | |
94cc52f9 | 14 | ($t1, $t2, $t3) = strike qw/66FC47BF95D1AA5ECA358F12C70AF3BA5C7E8F9A 5D4FD5A64E436A831383773F85FB38B888B9ECC9 B425907E5755031BDA4A8D1B6DCCACA97DA14C04/; |
fceb2d41 MG |
15 | } catch { |
16 | diag 'Error while calling strike:', "\n", Dumper $_ | |
17 | }; | |
27da1d36 MG |
18 | |
19 | subtest 'order' => sub { | |
20 | plan tests => 3; | |
94cc52f9 | 21 | is $t1->hash, '66FC47BF95D1AA5ECA358F12C70AF3BA5C7E8F9A', 'hash #1'; |
27da1d36 | 22 | is $t2->hash, '5D4FD5A64E436A831383773F85FB38B888B9ECC9', 'hash #2'; |
94cc52f9 | 23 | is $t3->hash, 'B425907E5755031BDA4A8D1B6DCCACA97DA14C04', 'hash #3' |
27da1d36 MG |
24 | }; |
25 | ||
94cc52f9 | 26 | is $t1->date, 1439319419, 'date'; |
27da1d36 | 27 | is $t2->title, 'FreeBSD 7.1 i386.DVD.iso', 'title'; |
94cc52f9 | 28 | like $t2->description, qr#FreeBSD#, 'description contains FreeBSD'; |
27da1d36 MG |
29 | |
30 | try { | |
31 | strike 'aaa'; | |
32 | } catch { | |
33 | is $_->{status}, 404, 'non-existent torrent status is 404'; | |
34 | }; | |
9373f0ad MG |
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 | ||
94cc52f9 MG |
44 | # Test disabled as it fails due to the API returning bad results |
45 | #my $p = strike_search 'Perl', 1; | |
46 | #say STDERR $p->hash; | |
47 | # | |
48 | #is @{$p->file_names}, $p->count, 'file_names has count elements'; | |
0eff1663 | 49 | |
94cc52f9 MG |
50 | # Test disabled as I can't find a torrent with an IMDB ID. Presumably |
51 | # this feature of the API is broken. | |
52 | #my $imdb = strike('ED70C185E3E3246F30B2FDB08D504EABED5EEA3F')->imdb; | |
53 | #is $imdb->{title}, 'The Walking Dead', 'imdb title'; |