[Bast-commits] r9919 - in ironman/Perlanet-IronMan/branches/dev: . t

idn at dev.catalyst.perl.org idn at dev.catalyst.perl.org
Sat Jun 30 18:13:28 GMT 2012


Author: idn
Date: 2012-06-30 18:13:28 +0000 (Sat, 30 Jun 2012)
New Revision: 9919

Added:
   ironman/Perlanet-IronMan/branches/dev/Makefile.PL
   ironman/Perlanet-IronMan/branches/dev/t/01_testdb_setup.t
Log:
Adding creation of test db and Makefile.PL

Added: ironman/Perlanet-IronMan/branches/dev/Makefile.PL
===================================================================
--- ironman/Perlanet-IronMan/branches/dev/Makefile.PL	                        (rev 0)
+++ ironman/Perlanet-IronMan/branches/dev/Makefile.PL	2012-06-30 18:13:28 UTC (rev 9919)
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+
+all_from('lib/Perlanet/IronMan.pm');
+
+requires 'IronMan::Schema';
+requires 'Perlanet'         => '0.56';
+requires 'HTML::Truncate';
+
+auto_install;
+
+WriteAll;

Added: ironman/Perlanet-IronMan/branches/dev/t/01_testdb_setup.t
===================================================================
--- ironman/Perlanet-IronMan/branches/dev/t/01_testdb_setup.t	                        (rev 0)
+++ ironman/Perlanet-IronMan/branches/dev/t/01_testdb_setup.t	2012-06-30 18:13:28 UTC (rev 9919)
@@ -0,0 +1,52 @@
+use strict;
+use warnings;
+
+use Perlanet::IronMan;
+use XML::Feed;
+use IronMan::Schema;
+use Test::More;
+
+my $schema;
+my $dir = "t/var/";
+my $file = "test.db";
+
+# Check the var directory exists for our testing.
+unless(-d $dir) {
+    mkdir($dir);
+}
+
+# Check we don't already have a test database prior to stomping all over it...
+if(-e $dir . $file) {
+    plan skip_all => 'Test database file already exists.  Skipping creation.';
+} else {
+    plan tests => 2;
+}
+
+ok($schema = IronMan::Schema->connect("dbi:SQLite:$dir$file"), "Creating a schema object");
+$schema->deploy();
+
+# Check the file exists
+my $file_exists = (-e $dir . $file);
+
+ok($file_exists, "Test database file exists");
+
+
+## Initialise with something to test against:
+$schema->resultset('Feed')->create({ id => 'fdave',
+                                     url => 'file:t/data/dave.xml',
+                                     link => 'http://blog.dave.org.uk/',
+                                     owner => 'Dave',
+                                     title => "Dave's Blog",
+                                   });
+$schema->resultset('Post')->create({ url => 'http://blog.dave.org.uk/2009/foo.html',
+                                     feed_id => 'dave',
+                                     title => 'Entry 1',
+                                     posted_on => DateTime->now,
+                                     body => 'blahblah',
+                                     author => 'Dave',
+                                     tags => 'perl'
+                                   });
+
+my $p = Perlanet::IronMan->new({ schema => $schema });
+
+done_testing();




More information about the Bast-commits mailing list