/[SQLSession]/trunk/t/00-model-Database.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/00-model-Database.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by dpavlin, Fri Dec 1 23:48:06 2006 UTC revision 15 by dpavlin, Sun Dec 3 14:01:53 2006 UTC
# Line 2  Line 2 
2  use warnings;  use warnings;
3  use strict;  use strict;
4    
5    use blib;
6    
7  =head1 DESCRIPTION  =head1 DESCRIPTION
8    
9  A basic test harness for the Database model.  A basic test harness for the Database model.
# Line 10  A basic test harness for the Database mo Line 12  A basic test harness for the Database mo
12    
13  use Jifty::Test tests => 11;  use Jifty::Test tests => 11;
14    
15    my $b = 2;      # number of bootstrap records
16    
17  # Make sure we can load the model  # Make sure we can load the model
18  use_ok('SQLSession::Model::Database');  use_ok('SQLSession::Model::Database');
19    
# Line 19  ok($system_user, "Found a system user"); Line 23  ok($system_user, "Found a system user");
23    
24  # Try testing a create  # Try testing a create
25  my $o = SQLSession::Model::Database->new(current_user => $system_user);  my $o = SQLSession::Model::Database->new(current_user => $system_user);
26  my ($id) = $o->create();  my ($id) = $o->create(
27            name => 'foo',
28            dsn => 'bar',
29    );
30  ok($id, "Database create returned success");  ok($id, "Database create returned success");
31  ok($o->id, "New Database has valid id set");  ok($o->id, "New Database has valid id set");
32  is($o->id, $id, "Create returned the right id");  is($o->id, $id, "Create returned the right id");
33    
34  # And another  # And another
35  $o->create();  $o->create(
36            name => 'baz',
37            dsn => 'baz',
38    );
39  ok($o->id, "Database create returned another value");  ok($o->id, "Database create returned another value");
40  isnt($o->id, $id, "And it is different from the previous one");  isnt($o->id, $id, "And it is different from the previous one");
41    
42  # Searches in general  # Searches in general
43  my $collection =  SQLSession::Model::DatabaseCollection->new(current_user => $system_user);  my $collection =  SQLSession::Model::DatabaseCollection->new(current_user => $system_user);
44  $collection->unlimit;  $collection->unlimit;
45  is($collection->count, 2, "Finds two records");  is($collection->count, $b + 2, "Finds two records");
46    
47  # Searches in specific  # Searches in specific
48  $collection->limit(column => 'id', value => $o->id);  $collection->limit(column => 'id', value => $o->id);
# Line 45  is($collection->count, 0, "Deleted row i Line 55  is($collection->count, 0, "Deleted row i
55    
56  # And the other one is still there  # And the other one is still there
57  $collection->unlimit;  $collection->unlimit;
58  is($collection->count, 1, "Still one left");  is($collection->count, $b + 1, "Still one left");
59    

Legend:
Removed from v.14  
changed lines
  Added in v.15

  ViewVC Help
Powered by ViewVC 1.1.26