Add expire.t
[libquvi-scripts.git] / tests / t / format_default.t
blobbc803564bc6f1781ef05b893c3c4d42c07873857
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;
34 plan skip_all => "TEST_SKIP rule"
35   if $q->test_skip("format_default");
37 my @dirs = qw(
38   data/format/default
39   data/format/default/ignore/length_bytes
40   );
42 my $c = $q->get_config;
43 push @dirs, "data/format/default/fixme" if $c->{fixme};
44 push @dirs, "data/format/default/nlfy"  if $c->{nlfy};
45 push @dirs, "data/format/default/nsfw"  if $c->{nsfw};
47 my @files = $q->find_json(@dirs);
49 plan skip_all => "Nothing to test" if scalar @files == 0;
50 plan tests => scalar @files * 2;
52 my $j   = $q->get_json_obj;
53 my $ign = qr|/ignore/(.*?)/|;
55 foreach (@files)
57   my $e = $q->read_json($_);
59   $q->mark_ignored(\$e, $1) if $_ =~ /$ign/;
61   my ($r, $o) = $q->run($e->{page_url}, "-qr");
62   is($r, 0, "quvi exit status == 0")
63     or diag $e->{page_url};
64 SKIP:
65   {
66     skip 'quvi exit status != 0', 1 if $r != 0;
67     cmp_deeply($j->decode($o), $e, "compare with $_")
68       or diag $e->{page_url};
69   }
72 # vim: set ts=2 sw=2 tw=72 expandtab: