Permalink
Browse files

repot collect failures

  • Loading branch information...
1 parent 44d2ba6 commit 5998bc52741b120755c4f5983c3d40590084678c @szabgab committed Sep 25, 2012
Showing with 36 additions and 13 deletions.
  1. +6 −2 lib/Dwimmer/Feed/Collector.pm
  2. +30 −11 t/100_feed_collector.t
@@ -82,12 +82,16 @@ sub collect {
alarm 0;
if ($err) {
main::LOG(" EXCEPTION: $err");
- $self->db->update_last_fetch($e->{id}, 'fail', $err);
+ if ($err =~ /TIMEOUT/) {
+ $self->db->update_last_fetch($e->{id}, 'fail_timeout', $err);
+ } else {
+ $self->db->update_last_fetch($e->{id}, 'fail_fetch', $err);
+ }
next;
}
if (not $feed) {
main::LOG(" ERROR: " . XML::Feed->errstr);
- $self->db->update_last_fetch($e->{id}, 'fail', XML::Feed->errstr);
+ $self->db->update_last_fetch($e->{id}, 'fail_nofeed', XML::Feed->errstr);
next;
}
if ($feed->title) {
View
@@ -62,7 +62,7 @@ my @sources2 = (
);
-plan tests => 97;
+plan tests => 101;
my $store = "$tempdir/data.db";
{
@@ -540,16 +540,35 @@ $disabled->{status} = 'disabled';
}
{
-# open my $atom, '>', "$tempdir/atom.xml" or die;
-# print $atom 'Garbage';
-# close $atom;
-# open my $rss, '>', "$tempdir/rss.xml" or die;
-# print $rss 'rss Garbage';
-# close $rss;
- my ($out, $err) = capture { system "$^X script/dwimmer_feed_collector.pl --store $store --collect" };
-# TODO better testing the log output? do we need that?
- like $out, qr{Elapsed time: [01]\s*$}, 'STDOUT is only elapsed time';
- is $err, '', 'no STDERR';
+ # creat an invalid feed to see how we handle errors
+ {
+ #open my $atom, '>', "$tempdir/atom.xml" or die;
+ #print $atom '<Garbage>in file';
+ #close $atom;
+ open my $rss, '>', "$tempdir/rss.xml" or die;
+ print $rss '<rss> Garbage';
+ close $rss;
+ my ($out, $err) = capture { system "$^X script/dwimmer_feed_collector.pl --store $store --collect" };
+ like $out, qr{Elapsed time: [01]\s*$}, 'STDOUT is only elapsed time';
+ is $err, '', 'no STDERR';
+ }
+ # list sources mostly to check the last_fetch fields
+
+ $sources[1]{last_fetch_error} = re('Malformed RSS');
+ $sources[1]{last_fetch_status} = 'fail_fetch';
+ {
+ my ($out, $err) = capture { system "$^X script/dwimmer_feed_admin.pl --store $store --listsource --site 1" };
+ my $data = check_dump($out);
+ cmp_deeply $data, [ $disabled, $sources[1] ], 'listed correctly' or diag $out;
+ is $err, '', 'no STDERR';
+ }
+ {
+ my ($out, $err) = capture { system "$^X script/dwimmer_feed_admin.pl --store $store --listsource --site 2" };
+ my $data = check_dump($out);
+ cmp_deeply $data, [ $sources2[0] ], 'listed correctly' or diag $out;
+ is $err, '', 'no STDERR';
+ }
+
}

0 comments on commit 5998bc5

Please sign in to comment.