Use HTTPS and include diagnostics in test
[webservice-strike.git] / t / WebService-Strike.t
CommitLineData
27da1d36
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
fceb2d41
MG
5use Data::Dumper qw/Dumper/;
6use Test::RequiresInternet qw/getstrike.net 443/;
9373f0ad 7use Test::More tests => 9;
27da1d36
MG
8use Try::Tiny;
9BEGIN { use_ok('WebService::Strike') };
10
fceb2d41
MG
11my ($t1, $t2, $t3);
12try {
13 ($t1, $t2, $t3) = strike qw/B425907E5755031BDA4A8D1B6DCCACA97DA14C04 5D4FD5A64E436A831383773F85FB38B888B9ECC9 85DF191A921C20B2DDAFF72368CAB93BA18C5ACE/;
14} catch {
15 diag 'Error while calling strike:', "\n", Dumper $_
16};
27da1d36
MG
17
18subtest '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
f447922d 25is $t1->date, 1420502400, 'date';
27da1d36
MG
26is $t2->title, 'FreeBSD 7.1 i386.DVD.iso', 'title';
27like $t1->torrent, qr/^d/, 'torrent file starts with d';
28
29try {
30 strike 'aaa';
31} catch {
32 is $_->{status}, 404, 'non-existent torrent status is 404';
33};
9373f0ad
MG
34
35my @debian = strike_search 'Debian';
36ok @debian > 10, 'search for Debian returned more than 10 results';
37try {
38 strike_search "nosuchstring$$";
39} catch {
40 is $_->{status}, 404, "search for nosuchstring$$ returned 404"
41};
42
43my $p = strike_search 'Perl', 1;
44is @{$p->file_names}, $p->count, 'file_names has count elements';
This page took 0.012292 seconds and 4 git commands to generate.