[Bast-commits] r8082 - in ironman/plagger: . t

castaway at dev.catalyst.perl.org castaway at dev.catalyst.perl.org
Sat Dec 12 18:10:30 GMT 2009


Author: castaway
Date: 2009-12-12 18:10:30 +0000 (Sat, 12 Dec 2009)
New Revision: 8082

Added:
   ironman/plagger/t/
   ironman/plagger/t/feed_rs.t
   ironman/plagger/t/var/
Log:
Tests for feed resultset (finding unknown feed posts)


Added: ironman/plagger/t/feed_rs.t
===================================================================
--- ironman/plagger/t/feed_rs.t	                        (rev 0)
+++ ironman/plagger/t/feed_rs.t	2009-12-12 18:10:30 UTC (rev 8082)
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use DateTime;
+use Test::More 'no_plan';
+
+use_ok('IronMan::Schema');
+
+unlink("t/var/test.db");
+my $schema = IronMan::Schema->connect("dbi:SQLite:t/var/test.db");
+$schema->deploy();
+
+## Initialise with something to test against:
+$schema->resultset('Feed')->create({ id => 'fred',
+                                     url => 'http://my.blog.example/foo.atom',
+                                     link => '',
+                                     owner => '',
+                                     title => "Fred's Blog",
+                                   });
+$schema->resultset('Post')->create({ url => 'http://my.blog.example/entry1.html',
+                                     feed_id => 'fred',
+                                     title => 'Entry 1',
+                                     posted_on => DateTime->now,
+                                     body => 'blahblah',
+                                   });
+
+## given three entries, one of which is the above, return the two unknown onws
+
+my $input = [ 'http://my.blog.example/foo.atom', 
+              { url => 'http://my.blog.example/entry2.html' },
+              { url => 'http://my.blog.example/entry1.html' },
+              { url => 'http://my.blog.example/entry3.html' },
+    ];
+
+is_deeply($schema->resultset('Feed')->filter_unseen(@$input),
+          [
+           { url => 'http://my.blog.example/entry2.html' },
+           { url => 'http://my.blog.example/entry3.html' },
+          ]);
+
+my $feed = XML::Feed->new('Atom');
+$feed->link('http://my.blog.example/foo.atom');
+my $e1 = XML::Feed::Entry->new('Atom');
+$e1->link('http://my.blog.example/entry2.html');
+$feed->add_entry($e1);
+my $e2 = XML::Feed::Entry->new('Atom');
+$e2->link('http://my.blog.example/entry1.html');
+$feed->add_entry($e2);
+my $e3 = XML::Feed::Entry->new('Atom');
+$e3->link('http://my.blog.example/entry3.html');
+$feed->add_entry($e3);
+
+is_deeply($schema->resultset('Feed')->filter_unseen($feed->link,
+                                                    $feed->entries),
+          [ $e1, $e3 ]);
+




More information about the Bast-commits mailing list