Skip to content

Commit

Permalink
test app schema
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Apr 22, 2009
1 parent 80b9637 commit fa4d56d
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/JiftyX/CloudTags.pm
Expand Up @@ -8,9 +8,11 @@ our $VERSION = '0.01';

has 'collection' => (is => 'rw', isa => 'Object');

sub new {
my $class = shift;
sub init {
my $self = shift;
my $collection = shift;
use Data::Dumper::Simple;
warn Dumper( $self );


}
Expand Down
8 changes: 7 additions & 1 deletion t/00-load.t
@@ -1,4 +1,5 @@
#!perl -T
#!perl
use lib 'lib';

use Test::More tests => 1;

Expand All @@ -7,3 +8,8 @@ BEGIN {
}

diag( "Testing JiftyX::CloudTags $JiftyX::CloudTags::VERSION, Perl $], $^X" );


use JiftyX::CloudTags;
my $cloudtags = new JiftyX::CloudTags;
ok( $cloudtags );
7 changes: 7 additions & 0 deletions t/TestApp/Makefile.PL
@@ -0,0 +1,7 @@
use inc::Module::Install;

name 'TestApp';
version '0.01';
requires 'Jifty' => '0.90409';

WriteAll;
16 changes: 16 additions & 0 deletions t/TestApp/bin/jifty
@@ -0,0 +1,16 @@
#!/usr/bin/env perl
use warnings;
use strict;
use UNIVERSAL::require;

BEGIN {
Jifty::Util->require or die $UNIVERSAL::require::ERROR;
my $root = Jifty::Util->app_root(quiet => 1);
unshift @INC, "$root/lib" if ($root);
}

use Jifty;
use Jifty::Script;

local $SIG{INT} = sub { warn "Stopped\n"; exit; };
Jifty::Script->dispatch();
73 changes: 73 additions & 0 deletions t/TestApp/etc/config.yml
@@ -0,0 +1,73 @@
---
framework:
AdminMode: 1
ApplicationClass: TestApp
ApplicationName: TestApp
ApplicationUUID: AB1AAC7A-2F31-11DE-94B8-5EDD63EE90E3
ConfigFileVersion: 4
Database:
AutoUpgrade: 1
CheckSchema: 1
Database: testapp
Driver: SQLite
Host: localhost
Password: ''
RecordBaseClass: Jifty::DBI::Record::Cachable
User: ''
Version: 0.0.1
DevelMode: 1
L10N:
PoDir: share/po
LogLevel: INFO
Mailer: Sendmail
MailerArgs: []

Plugins:
-
AdminUI: {}

-
CompressedCSSandJS: {}

-
ErrorTemplates: {}

-
Halo: {}

-
LetMe: {}

-
OnlineDocs: {}

-
REST: {}

-
SkeletonApp: {}

PubSub:
Backend: Memcached
Enable: ~
SkipAccessControl: 0
TemplateClass: TestApp::View
View:
Handlers:
- Jifty::View::Static::Handler
- Jifty::View::Declare::Handler
- Jifty::View::Mason::Handler
Web:
BaseURL: http://localhost
DataDir: var/mason
Globals: []

MasonConfig:
autoflush: 0
default_escape_flags: h
error_format: text
error_mode: fatal
Port: 8888
ServeStaticFiles: 1
StaticRoot: share/web/static
TemplateRoot: share/web/templates
23 changes: 23 additions & 0 deletions t/TestApp/lib/TestApp/Model/Labels.pm
@@ -0,0 +1,23 @@
use strict;
use warnings;

package TestApp::Model::Labels;
use Jifty::DBI::Schema;

use TestApp::Record schema {

column name =>
type is 'varchar';

column hit =>
type is 'integer';

column posts =>
refers_to 'TestApp::Model::PostsCollection';

};

# Your model-specific methods go here.

1;

14 changes: 14 additions & 0 deletions t/TestApp/lib/TestApp/Model/Posts.pm
@@ -0,0 +1,14 @@
use strict;
use warnings;

package TestApp::Model::Posts;
use Jifty::DBI::Schema;

use TestApp::Record schema {

};

# Your model-specific methods go here.

1;

49 changes: 49 additions & 0 deletions t/TestApp/t/00-model-Labels.t
@@ -0,0 +1,49 @@
#!/usr/bin/env perl
use warnings;
use strict;

=head1 DESCRIPTION
A basic test harness for the Labels model.
=cut

use Jifty::Test tests => 11;

# Make sure we can load the model
use_ok('TestApp::Model::Labels');

# Grab a system user
my $system_user = TestApp::CurrentUser->superuser;
ok($system_user, "Found a system user");

# Try testing a create
my $o = TestApp::Model::Labels->new(current_user => $system_user);
my ($id) = $o->create();
ok($id, "Labels create returned success");
ok($o->id, "New Labels has valid id set");
is($o->id, $id, "Create returned the right id");

# And another
$o->create();
ok($o->id, "Labels create returned another value");
isnt($o->id, $id, "And it is different from the previous one");

# Searches in general
my $collection = TestApp::Model::LabelsCollection->new(current_user => $system_user);
$collection->unlimit;
is($collection->count, 2, "Finds two records");

# Searches in specific
$collection->limit(column => 'id', value => $o->id);
is($collection->count, 1, "Finds one record with specific id");

# Delete one of them
$o->delete;
$collection->redo_search;
is($collection->count, 0, "Deleted row is gone");

# And the other one is still there
$collection->unlimit;
is($collection->count, 1, "Still one left");

49 changes: 49 additions & 0 deletions t/TestApp/t/00-model-Posts.t
@@ -0,0 +1,49 @@
#!/usr/bin/env perl
use warnings;
use strict;

=head1 DESCRIPTION
A basic test harness for the Posts model.
=cut

use Jifty::Test tests => 11;

# Make sure we can load the model
use_ok('TestApp::Model::Posts');

# Grab a system user
my $system_user = TestApp::CurrentUser->superuser;
ok($system_user, "Found a system user");

# Try testing a create
my $o = TestApp::Model::Posts->new(current_user => $system_user);
my ($id) = $o->create();
ok($id, "Posts create returned success");
ok($o->id, "New Posts has valid id set");
is($o->id, $id, "Create returned the right id");

# And another
$o->create();
ok($o->id, "Posts create returned another value");
isnt($o->id, $id, "And it is different from the previous one");

# Searches in general
my $collection = TestApp::Model::PostsCollection->new(current_user => $system_user);
$collection->unlimit;
is($collection->count, 2, "Finds two records");

# Searches in specific
$collection->limit(column => 'id', value => $o->id);
is($collection->count, 1, "Finds one record with specific id");

# Delete one of them
$o->delete;
$collection->redo_search;
is($collection->count, 0, "Deleted row is gone");

# And the other one is still there
$collection->unlimit;
is($collection->count, 1, "Still one left");

0 comments on commit fa4d56d

Please sign in to comment.