[Jifty-commit] r1456 - in Jifty-DBI/trunk: t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jul 3 11:41:22 EDT 2006


Author: alexmv
Date: Mon Jul  3 11:41:22 2006
New Revision: 1456

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/t/02records_cachable.t

Log:
 r14742 at zoq-fot-pik:  chmrr | 2006-07-03 11:41:02 -0400
  * Perltidy


Modified: Jifty-DBI/trunk/t/02records_cachable.t
==============================================================================
--- Jifty-DBI/trunk/t/02records_cachable.t	(original)
+++ Jifty-DBI/trunk/t/02records_cachable.t	Mon Jul  3 11:41:22 2006
@@ -1,6 +1,5 @@
 #!/usr/bin/perl -w
 
-
 use strict;
 use warnings;
 use File::Spec;
@@ -13,111 +12,120 @@
 my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
 plan tests => $total;
 
-foreach my $d ( @available_drivers ) {
+foreach my $d (@available_drivers) {
 SKIP: {
-    unless( has_schema( 'TestApp::Address', $d ) ) {
+        unless ( has_schema( 'TestApp::Address', $d ) ) {
             skip "No schema for '$d' driver", TESTS_PER_DRIVER;
-    }
-    unless( should_test( $d ) ) {
+        }
+        unless ( should_test($d) ) {
             skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
-    }
+        }
 
-    my $handle = get_handle( $d );
-    connect_handle( $handle );
-    isa_ok($handle->dbh, 'DBI::db');
-
-    my $ret = init_schema( 'TestApp::Address', $handle );
-    isa_ok($ret,'DBI::st', "Inserted the schema. got a statement handle back");
-
-{ # simple, load the same thing from cache
-    my $rec = TestApp::Address->new( handle => $handle );
-    isa_ok($rec, 'Jifty::DBI::Record');
-
-	my ($id) = $rec->create( Name => 'Jesse', Phone => '617 124 567');
-	ok($id,"Created record #$id");
-
-	ok($rec->load($id), "Loaded the record");
-	is($rec->id, $id, "The record has its id");
-	is($rec->name, 'Jesse', "The record's name is Jesse");
-
-    my $rec_cache = TestApp::Address->new( handle => $handle );
-    my ($status, $msg) = $rec_cache->load_by_cols( id => $id );
-    ok($status, 'loaded record');
-    is($rec_cache->id, $id, 'the same record as we created');
-    is($msg, 'Fetched from cache', 'we fetched record from cache');
-}
-
-    Jifty::DBI::Record::Cachable->flush_cache;
-
-{ # load by name then load by id, check that we fetch from hash
-    my $rec = TestApp::Address->new( handle => $handle );
-	ok($rec->load_by_cols( Name => 'Jesse' ), "Loaded the record");
-	is($rec->name, 'Jesse', "The record's name is Jesse");
-
-    my $rec_cache = TestApp::Address->new( handle => $handle );
-    my ($status, $msg) = $rec_cache->load_by_cols( id => $rec->id );
-    ok($status, 'loaded record');
-    is($rec_cache->id, $rec->id, 'the same record as we created');
-    is($msg, 'Fetched from cache', 'we fetched record from cache');
-}
+        my $handle = get_handle($d);
+        connect_handle($handle);
+        isa_ok( $handle->dbh, 'DBI::db' );
+
+        my $ret = init_schema( 'TestApp::Address', $handle );
+        isa_ok( $ret, 'DBI::st',
+            "Inserted the schema. got a statement handle back" );
+
+        {    # simple, load the same thing from cache
+            my $rec = TestApp::Address->new( handle => $handle );
+            isa_ok( $rec, 'Jifty::DBI::Record' );
+
+            my ($id)
+                = $rec->create( Name => 'Jesse', Phone => '617 124 567' );
+            ok( $id, "Created record #$id" );
+
+            ok( $rec->load($id), "Loaded the record" );
+            is( $rec->id, $id, "The record has its id" );
+            is( $rec->name, 'Jesse', "The record's name is Jesse" );
+
+            my $rec_cache = TestApp::Address->new( handle => $handle );
+            my ( $status, $msg ) = $rec_cache->load_by_cols( id => $id );
+            ok( $status, 'loaded record' );
+            is( $rec_cache->id, $id, 'the same record as we created' );
+            is( $msg, 'Fetched from cache', 'we fetched record from cache' );
+        }
+
+        Jifty::DBI::Record::Cachable->flush_cache;
+
+        {    # load by name then load by id, check that we fetch from hash
+            my $rec = TestApp::Address->new( handle => $handle );
+            ok( $rec->load_by_cols( Name => 'Jesse' ), "Loaded the record" );
+            is( $rec->name, 'Jesse', "The record's name is Jesse" );
+
+            my $rec_cache = TestApp::Address->new( handle => $handle );
+            my ( $status, $msg ) = $rec_cache->load_by_cols( id => $rec->id );
+            ok( $status, 'loaded record' );
+            is( $rec_cache->id, $rec->id, 'the same record as we created' );
+            is( $msg, 'Fetched from cache', 'we fetched record from cache' );
+        }
+
+        Jifty::DBI::Record::Cachable->flush_cache;
+
+        {    # load_by_cols and undef, 0 or '' values
+            my $rec = TestApp::Address->new( handle => $handle );
+            my ($id) = $rec->create( Name => 'EmptyPhone', Phone => '' );
+            ok( $id, "Created record #$id" );
+            ($id) = $rec->create( Name => 'ZeroPhone', Phone => 0 );
+            ok( $id, "Created record #$id" );
+            ($id) = $rec->create( Name => 'UndefPhone', Phone => undef );
+            ok( $id, "Created record #$id" );
+
+            Jifty::DBI::Record::Cachable->flush_cache;
+
+            ok( $rec->load_by_cols( Phone => undef ), "Loaded the record" );
+        TODO:
+            {
+                local $TODO = "Loading undef PKs doesn't work properly";
+                is( $rec->name, 'UndefPhone', "UndefPhone record" );
+            }
+
+            # XXX: JDBI turns undef into '' which makes me really sad //ruz
+            # test should be:
+            # is($rec->phone, undef, "Phone number is undefined");
+            is( $rec->phone, '', "Phone number is undefined" );
+
+            ok( $rec->load_by_cols( Phone => '' ), "Loaded the record" );
+            is( $rec->name,  'EmptyPhone', "EmptyPhone record" );
+            is( $rec->phone, '',           "Phone number is empty string" );
+
+            ok( $rec->load_by_cols( Phone => 0 ), "Loaded the record" );
+            is( $rec->name,  'ZeroPhone', "ZeroPhone record" );
+            is( $rec->phone, 0,           "Phone number is zero" );
+
+     # XXX: next thing fails, looks like operator is mandatory
+     # ok($rec->load_by_cols( Phone => { value => 0 } ), "Loaded the record");
+            ok( $rec->load_by_cols(
+                    Phone => { operator => '=', value => 0 }
+                ),
+                "Loaded the record"
+            );
+            is( $rec->name,  'ZeroPhone', "ZeroPhone record" );
+            is( $rec->phone, 0,           "Phone number is zero" );
+        }
+
+        Jifty::DBI::Record::Cachable->flush_cache;
+
+        {    # case insensetive columns names
+            my $rec = TestApp::Address->new( handle => $handle );
+            ok( $rec->load_by_cols( Name => 'Jesse' ), "Loaded the record" );
+            is( $rec->name, 'Jesse', "loaded record" );
+
+            my $rec_cache = TestApp::Address->new( handle => $handle );
+            my ( $status, $msg )
+                = $rec_cache->load_by_cols( name => 'Jesse' );
+            ok( $status, 'loaded record' );
+            is( $rec_cache->id, $rec->id, 'the same record as we created' );
+            is( $msg, 'Fetched from cache', 'we fetched record from cache' );
+        }
 
-    Jifty::DBI::Record::Cachable->flush_cache;
+        Jifty::DBI::Record::Cachable->flush_cache;
 
-{ # load_by_cols and undef, 0 or '' values
-    my $rec = TestApp::Address->new( handle => $handle );
-	my ($id) = $rec->create( Name => 'EmptyPhone', Phone => '');
-	ok($id,"Created record #$id");
-	($id) = $rec->create( Name => 'ZeroPhone', Phone => 0);
-	ok($id,"Created record #$id");
-	($id) = $rec->create( Name => 'UndefPhone', Phone => undef);
-	ok($id,"Created record #$id");
-
-    Jifty::DBI::Record::Cachable->flush_cache;
-
-	ok($rec->load_by_cols( Phone => undef ), "Loaded the record");
-  TODO: 
-    {
-        local $TODO = "Loading undef PKs doesn't work properly";
-	is($rec->name, 'UndefPhone', "UndefPhone record");
+        cleanup_schema( 'TestApp::Address', $handle );
     }
-    # XXX: JDBI turns undef into '' which makes me really sad //ruz
-    # test should be:
-	# is($rec->phone, undef, "Phone number is undefined");
-	is($rec->phone, '', "Phone number is undefined");
-
-	ok($rec->load_by_cols( Phone => '' ), "Loaded the record");
-	is($rec->name, 'EmptyPhone', "EmptyPhone record");
-	is($rec->phone, '', "Phone number is empty string");
-
-	ok($rec->load_by_cols( Phone => 0 ), "Loaded the record");
-	is($rec->name, 'ZeroPhone', "ZeroPhone record");
-	is($rec->phone, 0, "Phone number is zero");
-
-    # XXX: next thing fails, looks like operator is mandatory
-	# ok($rec->load_by_cols( Phone => { value => 0 } ), "Loaded the record");
-	ok($rec->load_by_cols( Phone => { operator => '=', value => 0 } ), "Loaded the record");
-	is($rec->name, 'ZeroPhone', "ZeroPhone record");
-	is($rec->phone, 0, "Phone number is zero");
-}
-
-    Jifty::DBI::Record::Cachable->flush_cache;
-
-{ # case insensetive columns names
-    my $rec = TestApp::Address->new( handle => $handle );
-	ok($rec->load_by_cols( Name => 'Jesse' ), "Loaded the record");
-	is($rec->name, 'Jesse', "loaded record");
-
-    my $rec_cache = TestApp::Address->new( handle => $handle );
-    my ($status, $msg) = $rec_cache->load_by_cols( name => 'Jesse' );
-    ok($status, 'loaded record');
-    is($rec_cache->id, $rec->id, 'the same record as we created');
-    is($msg, 'Fetched from cache', 'we fetched record from cache');
-}
-
-    Jifty::DBI::Record::Cachable->flush_cache;
-
-	cleanup_schema( 'TestApp::Address', $handle );
-}} # SKIP, foreach blocks
+}    # SKIP, foreach blocks
 
 1;
 
@@ -125,7 +133,7 @@
 use base qw/Jifty::DBI::Record::Cachable/;
 
 sub schema_mysql {
-<<EOF;
+    <<EOF;
 CREATE TEMPORARY table addresses (
         id integer AUTO_INCREMENT,
         name varchar(36),
@@ -138,7 +146,7 @@
 }
 
 sub schema_pg {
-<<EOF;
+    <<EOF;
 CREATE TEMPORARY table addresses (
         id serial PRIMARY KEY,
         name varchar,
@@ -152,7 +160,7 @@
 
 sub schema_sqlite {
 
-<<EOF;
+    <<EOF;
 CREATE table addresses (
         id  integer primary key,
         name varchar(36),
@@ -166,20 +174,18 @@
 1;
 
 package TestApp::Address::Schema;
+
 BEGIN {
-use Jifty::DBI::Schema;
+    use Jifty::DBI::Schema;
 
-column name =>
-  type is 'varchar(14)';
+    column name => type is 'varchar(14)';
 
-column phone =>
-  type is 'varchar(18)',
+    column phone => type is 'varchar(18)';
 
-column address =>
-  type is 'varchar(50)',
-  default is '';
+    column
+        address => type is 'varchar(50)',
+        default is '';
 
-column employee_id =>
-  type is 'int(8)';
+    column employee_id => type is 'int(8)';
 }
 1;


More information about the Jifty-commit mailing list