4 |
|
|
5 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
6 |
|
|
7 |
A basic test harness for the StrixSite model. |
A basic test harness for the StrixInstance model. |
8 |
|
|
9 |
=cut |
=cut |
10 |
|
|
11 |
use Jifty::Test tests => 11; |
use Jifty::Test tests => 11; |
12 |
|
|
13 |
# Make sure we can load the model |
# Make sure we can load the model |
14 |
use_ok('A3C::Model::StrixSite'); |
use_ok('A3C::Model::StrixInstance'); |
15 |
|
|
16 |
# Grab a system user |
# Grab a system user |
17 |
my $system_user = A3C::CurrentUser->superuser; |
my $system_user = A3C::CurrentUser->superuser; |
18 |
ok($system_user, "Found a system user"); |
ok($system_user, "Found a system user"); |
19 |
|
|
20 |
# Try testing a create |
# Try testing a create |
21 |
my $o = A3C::Model::StrixSite->new(current_user => $system_user); |
my $o = A3C::Model::StrixInstance->new(current_user => $system_user); |
22 |
my ($id) = $o->create( site => 'foo', _dbserver => 'localhost', _dbname => 'foo' ); |
my ($id) = $o->create( instance => 'foo', _dbserver => 'localhost', _dbname => 'foo' ); |
23 |
ok($id, "StrixSite create returned success"); |
ok($id, "StrixInstance create returned success"); |
24 |
ok($o->id, "New StrixSite has valid id set"); |
ok($o->id, "New StrixInstance has valid id set"); |
25 |
is($o->id, $id, "Create returned the right id"); |
is($o->id, $id, "Create returned the right id"); |
26 |
|
|
27 |
# And another |
# And another |
28 |
$o->create( site => 'bar', _dbserver => 'localhost', _dbname => 'bar' ); |
$o->create( instance => 'bar', _dbserver => 'localhost', _dbname => 'bar' ); |
29 |
ok($o->id, "StrixSite create returned another value"); |
ok($o->id, "StrixInstance create returned another value"); |
30 |
isnt($o->id, $id, "And it is different from the previous one"); |
isnt($o->id, $id, "And it is different from the previous one"); |
31 |
|
|
32 |
# Searches in general |
# Searches in general |
33 |
my $collection = A3C::Model::StrixSiteCollection->new(current_user => $system_user); |
my $collection = A3C::Model::StrixInstanceCollection->new(current_user => $system_user); |
34 |
$collection->unlimit; |
$collection->unlimit; |
35 |
is($collection->count, 2, "Finds two records"); |
is($collection->count, 2, "Finds two records"); |
36 |
|
|