FIX: website/liveleak.lua: media stream URL pattern
[libquvi-scripts.git] / tests / t / d / url.t
blobd5fe655eea3699e82dc37cab9193c778a3e3336f
1 # libquvi-scripts
2 # Copyright (C) 2011  Toni Gundogdu <legatvs@gmail.com>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 # 02110-1301, USA.
19 use warnings;
20 use strict;
22 use Test::More;
24 eval "use JSON::XS";
25 plan skip_all => "JSON::XS required for testing" if $@;
27 eval "use Test::Deep";
28 plan skip_all => "Test::Deep required for testing" if $@;
30 use Test::Quvi;
32 my $q = Test::Quvi->new;
33 my $c = $q->get_config;
35 plan skip_all =>
36   "URL required for testing, use ':: --url URL' or ('--json-file FILE')"
37   unless $c->{url}
38     or $c->{json_file};    # --url or --json-file (read URL from json)
40 my $e;
41 my $u = $c->{url};
42 if (!$u)
44   $e = $q->read_json($c->{json_file});
45   plan skip_all =>
46     "URL required, JSON did not contain 'page_url', use --url URL"
47     unless $e->{page_url};
48   $u = $e->{page_url};
51 my $t = 1;
52 $t += 1 if $c->{json_file};
53 plan tests => $t;
55 my ($r, $o) = $q->run($u);
56 is($r, 0, "quvi exit status == 0")
57   or diag $c->{url};
58 if ($c->{json_file})
60 SKIP:
61   {
62     skip 'quvi exit status != 0', 1 if $r != 0;
63     my $f = $c->{json_file};
64     my $j = $q->get_json_obj;
65     cmp_deeply($j->decode($o), $e, "compare with $f")
66       or diag $c->{url};
67   }