/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations)
Sun Dec 3 14:01:53 2006 UTC (17 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1413 byte(s)
great rename: Model::Page is now Model::Query (which is more sane), tests pass,
bootstrap fills two records for each model
1 dpavlin 1 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5 dpavlin 15 use blib;
6    
7 dpavlin 1 =head1 DESCRIPTION
8    
9     A basic test harness for the Database model.
10    
11     =cut
12    
13     use Jifty::Test tests => 11;
14    
15 dpavlin 15 my $b = 2; # number of bootstrap records
16    
17 dpavlin 1 # Make sure we can load the model
18     use_ok('SQLSession::Model::Database');
19    
20     # Grab a system user
21     my $system_user = SQLSession::CurrentUser->superuser;
22     ok($system_user, "Found a system user");
23    
24     # Try testing a create
25     my $o = SQLSession::Model::Database->new(current_user => $system_user);
26 dpavlin 15 my ($id) = $o->create(
27     name => 'foo',
28     dsn => 'bar',
29     );
30 dpavlin 1 ok($id, "Database create returned success");
31     ok($o->id, "New Database has valid id set");
32     is($o->id, $id, "Create returned the right id");
33    
34     # And another
35 dpavlin 15 $o->create(
36     name => 'baz',
37     dsn => 'baz',
38     );
39 dpavlin 1 ok($o->id, "Database create returned another value");
40     isnt($o->id, $id, "And it is different from the previous one");
41    
42     # Searches in general
43     my $collection = SQLSession::Model::DatabaseCollection->new(current_user => $system_user);
44     $collection->unlimit;
45 dpavlin 15 is($collection->count, $b + 2, "Finds two records");
46 dpavlin 1
47     # Searches in specific
48     $collection->limit(column => 'id', value => $o->id);
49     is($collection->count, 1, "Finds one record with specific id");
50    
51     # Delete one of them
52     $o->delete;
53     $collection->redo_search;
54     is($collection->count, 0, "Deleted row is gone");
55    
56     # And the other one is still there
57     $collection->unlimit;
58 dpavlin 15 is($collection->count, $b + 1, "Still one left");
59 dpavlin 1

  ViewVC Help
Powered by ViewVC 1.1.26