Split from git://repo.or.cz/quvi.git
[libquvi-scripts.git] / tests / t / shortened.t
blobd9b0047dcc51579b2245a1684bc32b785b9078aa
2 use warnings;
3 use strict;
5 use Test::More;
7 eval "use JSON::XS";
8 plan skip_all => "JSON::XS required for testing" if $@;
10 eval "use Test::Deep";
11 plan skip_all => "Test::Deep required for testing" if $@;
13 plan tests => 4;
15 use Test::Quvi;
17 my $q = Test::Quvi->new;
19 plan skip_all => "TEST_SKIP rule"
20   if $q->test_skip("shortened");
22 # All roads lead to (same) URL.
23 my @u = (
25   # Resolved without querying over the internet.
26   "http://dai.ly/cityofscars",
28   # Query over the internet to resolved this one.
29   "http://goo.gl/18ol"
32 my $f = "data/resolve/shortened.json";
34 # 1=prepend --data-root (if specified in cmdline)
35 my $e = $q->read_json($f, 1);
37 # dailymotion returns content-length that varies from
38 # time to time, no idea why.
39 $q->mark_ignored(\$e, 'length_bytes');
41 foreach (@u)
43   my ($r, $o) = $q->run($_, "-q");
44   is($r, 0, "quvi exit status == 0")
45     or diag $_;
46 SKIP:
47   {
48     skip 'quvi exit status != 0', 1 if $r != 0;
49     my $j = $q->get_json_obj;
50     cmp_deeply($j->decode($o), $e, "compare with $f")
51       or diag $_;
52   }
55 # vim: set ts=2 sw=2 tw=72 expandtab: