Add expire.t
[libquvi-scripts.git] / tests / t / shortened.t
blobf2b053ad8124aa232a49072aac7bad78bd9aebe2
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 plan tests => 4;
32 use Test::Quvi;
34 my $q = Test::Quvi->new;
36 plan skip_all => "TEST_SKIP rule"
37   if $q->test_skip("shortened");
39 # All roads lead to (same) URL.
40 my @u = (
42   # Resolved without querying over the internet.
43   "http://dai.ly/cityofscars",
45   # Query over the internet to resolved this one.
46   "http://goo.gl/18ol"
49 my $f = "data/resolve/shortened.json";
51 # 1=prepend --data-root (if specified in cmdline)
52 my $e = $q->read_json($f, 1);
54 # dailymotion returns content-length that varies from
55 # time to time, no idea why.
56 $q->mark_ignored(\$e, 'length_bytes');
58 foreach (@u)
60   my ($r, $o) = $q->run($_, "-q");
61   is($r, 0, "quvi exit status == 0")
62     or diag $_;
63 SKIP:
64   {
65     skip 'quvi exit status != 0', 1 if $r != 0;
66     my $j = $q->get_json_obj;
67     cmp_deeply($j->decode($o), $e, "compare with $f")
68       or diag $_;
69   }
72 # vim: set ts=2 sw=2 tw=72 expandtab: