[Bast-commits] r8980 - ironman/IronMan-Schema/t

idn at dev.catalyst.perl.org idn at dev.catalyst.perl.org
Thu Mar 11 20:47:44 GMT 2010


Author: idn
Date: 2010-03-11 20:47:44 +0000 (Thu, 11 Mar 2010)
New Revision: 8980

Added:
   ironman/IronMan-Schema/t/04_resultset_post.t
Log:
Adding tests for post

Added: ironman/IronMan-Schema/t/04_resultset_post.t
===================================================================
--- ironman/IronMan-Schema/t/04_resultset_post.t	                        (rev 0)
+++ ironman/IronMan-Schema/t/04_resultset_post.t	2010-03-11 20:47:44 UTC (rev 8980)
@@ -0,0 +1,29 @@
+use warnings;
+use Test::More tests => 3;
+
+use IronMan::Schema;
+use DateTime;
+
+my $dir = "t/var/";
+my $file = "test.db";
+
+my $schema = IronMan::Schema->connect("dbi:SQLite:$dir$file");
+
+# Create a DateTime for right now.
+my $dt = DateTime->now;
+
+my $posts;
+
+# Get posts_for_day
+ok($posts = $schema->resultset('Post')->posts_for_day($dt));
+
+# Get posts_for_month
+ok($posts = $schema->resultset('Post')->posts_for_month($dt));
+
+# Calculate the DateTime for start and end of our DateTime created above
+my $month_start = $dt->clone()->truncate( 'to' => 'month');
+my $month_end = $month_start->clone()->add( 'months' => 1 )->subtract( 'seconds' => 1 );
+
+# Get posts_for_daterange
+ok($posts = $schema->resultset('Post')->posts_for_daterange($month_start, $month_end));
+




More information about the Bast-commits mailing list