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
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 $@;
32 my $q = Test::Quvi->new;
34 plan skip_all => "TEST_SKIP rule"
35 if $q->test_skip("redirect");
39 my $j = $q->get_json_obj;
42 test_redirect_url( # Test self.redirect_url in collegehumor.lua
43 "http://www.dorkly.com/embed/17349/ridiculous-way-to-get-ammo-to-teammates-in-battlefield-bad-company-2",
44 "data/resolve/redirect_url_dorkly.json"
48 test_redirect_url( # Test self.redirect_url in ted.lua
49 "http://www.ted.com/talks/paul_lewis_crowdsourcing_the_news.html",
50 "data/resolve/redirect_url_ted.json"
53 test_redirect_url( # Test (one of three) self.redirect_url in tcmag.lua
54 "http://www.tcmag.com/magazine/traffic_in_ho_chi_minh_city_time_lapse/",
55 "data/resolve/redirect_url_tcmag.json"
58 test_redirect_url( # Test self.redirect_url in bikeradar.lua
59 "http://www.bikeradar.com/videos/giant-defy-advanced-2-road-bike-of-the-year-2013-winner-Vy3za54p50D2U?side=choice",
60 "data/resolve/redirect_url_bikeradar.json"
63 test_redirect_url( # Test self.redirect_url in 101greatgoals.lua
64 "http://www.101greatgoals.com/gvideos/welsh-premier-goal-of-the-season-glenn-rule-airbus-uk-broughton-v-prestatyn-town/",
65 "data/resolve/redirect_url_101greatgoals.json"
68 test_redirect_url( # Test self.redirect_url in liveleak.lua
69 "http://www.liveleak.com/view?i=fff_1368950004",
70 "data/resolve/redirect_url_liveleak.json"
73 test_url_shortener( # Test URL shortener support
74 "http://is.gd/WipJlL", # -> http://vimeo.com/42605731
75 "data/format/default/vimeo.json"
80 my ($url, $json) = @_;
81 my ($r, $o) = $q->run($url, "-vq");
82 is($r, 0, "quvi exit status == 0") or diag $url;
85 skip 'quvi exit status != 0', 1 if $r != 0;
86 my $e = $q->read_json($json, 1)
87 ; # 1=prepend --data-root (if specified in cmdline)
88 cmp_deeply($j->decode($o), $e, "compare with $json")
93 sub test_url_shortener
95 my ($url, $json) = @_;
96 my ($r, $o) = $q->run($url, "-vq");
97 is($r, 0, "quvi exit status == 0") or diag $url;
100 skip 'quvi exit status != 0', 1 if $r != 0;
101 my $e = $q->read_json($json, 1)
102 ; # 1=prepend --data-root (if specified in cmdline)
103 cmp_deeply($j->decode($o), $e, "compare with $json")
108 # vim: set ts=2 sw=2 tw=72 expandtab: