[siesta-commit] siesta/t 07list.t,1.24,1.25 07user.t,1.12,1.13

[prev] [thread] [next] [lurker] [Date index for 2003/03/15]

From: clampr
Subject: [siesta-commit] siesta/t 07list.t,1.24,1.25 07user.t,1.12,1.13
Date: 22:11 on 15 Mar 2003
Update of /cvsroot/siesta/siesta/t
In directory sc8-pr-cvs1:/tmp/cvs-serv20088/t

Modified Files:
	07list.t 07user.t 
Log Message:
rencapsulate the storage

Index: 07list.t
===================================================================
RCS file: /cvsroot/siesta/siesta/t/07list.t,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- 07list.t	15 Mar 2003 21:39:18 -0000	1.24
+++ 07list.t	15 Mar 2003 22:11:56 -0000	1.25
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 43;
+use Test::More tests => 36;
 use Test::MockObject;
 use Siesta;
 use Siesta::List;
@@ -50,42 +50,20 @@
 is( scalar $list->members, $count + 1 );
 ok( $list->is_member('bob@xxxxxxxx.xxxxxxxxxx') );
 
-# test instantiating from hash
-my $test_list = Siesta::List->new_from_hash( name  => 'testing',
-                                             owner => 'test@xxxxxxx.xxx', );
-
-ok( $test_list, "list created from hash" );
-isa_ok( $test_list, "Siesta::List" );
-
-# save that
-ok( Siesta->storage->save_list($test_list) );
-
-$test_list = undef;
-
-# now reload it
-$test_list = Siesta::List->new( 'testing');
-ok( $test_list, "list reloaded" );
-isa_ok( $test_list, "Siesta::List" );
-is( $test_list->owner, 'test@xxxxxxx.xxx', "correct data" );
-
-# now delete it
-ok( Siesta->storage->delete_list($test_list) );
-$test_list = Siesta::List->new('testing');
-is( $test_list, undef );
-
-# now try all those again with class methods
+# instantiate from a hash
 my $again = Siesta::List->new_from_hash( name  => 'testing',
                                          owner => 'test@xxxxxxx.xxx', );
 
 ok($again);
 isa_ok( $again, "Siesta::List" );
-ok( $again->save );
-$again = undef;
+ok( $again->save, "saved" );
+
 $again = Siesta::List->new('testing');
+ok( $again, " loaded the testing list ");
 is( $again->owner, 'test@xxxxxxx.xxx' );
-ok( $again->delete );
-$test_list = Siesta::List->new('testing');
-is( $test_list, undef );
+ok( $again->delete, "deleted" );
+
+is( Siesta::List->new('testing'), undef, " and it really went" );
 
 # make sure that we insert when there's nothing there
 # before and update when there is

Index: 07user.t
===================================================================
RCS file: /cvsroot/siesta/siesta/t/07user.t,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- 07user.t	15 Mar 2003 21:43:13 -0000	1.12
+++ 07user.t	15 Mar 2003 22:11:56 -0000	1.13
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 24;
+use Test::More tests => 19;
 use Test::MockObject;
 use Siesta;
 use Siesta::User;
@@ -22,58 +22,39 @@
 ok( $other, "user created from hash" );
 isa_ok( $other, "Siesta::User" );
 
-# save that
-ok( $other->save );
-ok( $other->id, "saving allocated an id" );
-
-$other = undef;
-
-# we now reload that user
-$other = Siesta::User->new_from_email('bluntman@xxxxxxx.xxx');
-ok( $other, "user reloaded" );
-isa_ok( $other, "Siesta::User" );
-is( $other->forename, 'bluntman', "correct data" );
-
-# now delete it
-ok( Siesta->storage->delete_user($other) );
-
-# now reload it
-is( Siesta::User->new_from_email('bluntman@xxxxxxx.xxx'), undef );
+my $again = Siesta::User->new_from_hash
+  (
+   email    => 'chronic@xxxxxxx.xxx',
+   forename => 'charles',
+   surname  => 'hronic'
+  );
 
-# now try all these as User class methods
-my $again = Siesta::User->new_from_hash(
-                                         email    => 'chronic@xxxxxxx.xxx',
-                                         forename => 'charles',
-                                         surname  => 'hronic'
-                                         );
 ok($again);
 isa_ok( $again, 'Siesta::User' );
-ok( $again->save );
-$again = undef;
+ok( $again->save, "saved" );
+ok( $again->id, "saving allocated and id");
+
 $again = Siesta::User->new_from_email('chronic@xxxxxxx.xxx');
 is( $again->forename, 'charles' );
 ok( $again->delete );
-$again = Siesta::User->new('charles@xxxxxxx.xxx');
+$again = Siesta::User->new_from_email('charles@xxxxxxx.xxx');
 is( $again, undef );
 
 # make sure that we insert when there's nothing there
 # before and update when there is
 my $us = Siesta::User->new_from_hash( email => 'test@test' );
 ok( $us->save, "saved 'test\@test'" );
-my $flag = 0;
-foreach my $user ( Siesta->users ) {
-    $flag++ if ( $user->email eq 'test@test' );
-}
-is( $flag, 1, "inserted" );
-ok( $us->forename('test') );
-ok( $us->save );
-$flag = 0;
-foreach my $user ( Siesta->users ) {
-    $flag++ if ( $user->email eq 'test@test' );
-}
 
-is( $flag, 1, "updated" );
-is( $us->forename, 'test' );
+my $count = grep { $_->email eq 'test@test' } Siesta->users;
+is( $count, 1, "inserted" );
 
-# option
-# config
+ok( $us->forename('test'), "set forename" );
+ok( $us->save, "saved again" );
+
+ok( $us = Siesta::User->new_from_email('test@test'), "and reloaded" );
+
+$count = grep { $_->email eq 'test@test' } Siesta->users;
+is( $count, 1, "still only 1 of them" );
+is( $us->forename, 'test', 'forename is set' );
+# cleanup
+$us->delete;



Generated at 13:57 on 01 Jul 2004 by mariachi 0.52