[Bast-commits] r5047 - in DBIx-Class/0.08/trunk/t: . lib lib/DBICTest/Schema

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Nov 2 16:55:31 GMT 2008


Author: ribasushi
Date: 2008-11-02 16:55:31 +0000 (Sun, 02 Nov 2008)
New Revision: 5047

Modified:
   DBIx-Class/0.08/trunk/t/88result_set_column.t
   DBIx-Class/0.08/trunk/t/lib/DBICTest.pm
   DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/BooksInLibrary.pm
   DBIx-Class/0.08/trunk/t/lib/sqlite.sql
Log:
Test prompted by discussion about tasty stuff

Modified: DBIx-Class/0.08/trunk/t/88result_set_column.t
===================================================================
--- DBIx-Class/0.08/trunk/t/88result_set_column.t	2008-11-02 16:54:46 UTC (rev 5046)
+++ DBIx-Class/0.08/trunk/t/88result_set_column.t	2008-11-02 16:55:31 UTC (rev 5047)
@@ -7,7 +7,7 @@
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 11; 
+plan tests => 14;
 
 my $cd;
 my $rs = $cd = $schema->resultset("CD")->search({});
@@ -50,3 +50,11 @@
   my $rsc = $rs->get_column('year');
   is( $rsc->{_parent_resultset}->{attrs}->{prefetch}, undef, 'prefetch wiped' );
 }
+
+# test sum()
+is ($schema->resultset('BooksInLibrary')->get_column ('price')->sum, 125, 'Sum of a resultset works correctly');
+
+# test sum over search_related
+my $owner = $schema->resultset('Owners')->find ({ name => 'Newton' });
+ok ($owner->books->count > 1, 'Owner Newton has multiple books');
+is ($owner->search_related ('books')->get_column ('price')->sum, 60, 'Correctly calculated price of all owned books');

Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/BooksInLibrary.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/BooksInLibrary.pm	2008-11-02 16:54:46 UTC (rev 5046)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/BooksInLibrary.pm	2008-11-02 16:55:31 UTC (rev 5047)
@@ -20,6 +20,10 @@
     data_type => 'varchar',
     size      => '100',
   },
+  'price' => {
+    data_type => 'integer',
+    is_nullable => 1,
+  },
 );
 __PACKAGE__->set_primary_key('id');
 

Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest.pm	2008-11-02 16:54:46 UTC (rev 5046)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest.pm	2008-11-02 16:55:31 UTC (rev 5047)
@@ -315,10 +315,10 @@
     ]);
 
     $schema->populate('BooksInLibrary', [
-        [ qw/id owner title source/ ],
-        [ 1, 1, "Programming Perl", "Library" ],
-        [ 2, 1, "Dynamical Systems", "Library" ],
-        [ 3, 2, "Best Recipe Cookbook", "Library" ],
+        [ qw/id owner title source price/ ],
+        [ 1, 1, "Programming Perl", "Library", 23 ],
+        [ 2, 1, "Dynamical Systems", "Library",  37 ],
+        [ 3, 2, "Best Recipe Cookbook", "Library", 65 ],
     ]);
 }
 

Modified: DBIx-Class/0.08/trunk/t/lib/sqlite.sql
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/sqlite.sql	2008-11-02 16:54:46 UTC (rev 5046)
+++ DBIx-Class/0.08/trunk/t/lib/sqlite.sql	2008-11-02 16:55:31 UTC (rev 5047)
@@ -1,6 +1,6 @@
 -- 
 -- Created by SQL::Translator::Producer::SQLite
--- Created on Fri Oct 24 21:31:55 2008
+-- Created on Sun Nov  2 15:27:04 2008
 -- 
 BEGIN TRANSACTION;
 
@@ -44,7 +44,8 @@
   id INTEGER PRIMARY KEY NOT NULL,
   source varchar(100) NOT NULL,
   owner integer NOT NULL,
-  title varchar(100) NOT NULL
+  title varchar(100) NOT NULL,
+  price integer
 );
 
 




More information about the Bast-commits mailing list