From: Aran Deltac Date: Sun, 19 Mar 2006 06:12:21 +0000 (+0000) Subject: Very basic tests for DBIC:Positioned. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=93cec8c3b4789ff9e7f09e06da0078eb3164486f;p=dbsrgits%2FDBIx-Class-Historic.git Very basic tests for DBIC:Positioned. --- diff --git a/t/helperrels/26positioned.t b/t/helperrels/26positioned.t new file mode 100644 index 0000000..8e42bbd --- /dev/null +++ b/t/helperrels/26positioned.t @@ -0,0 +1,7 @@ +use Test::More; +use lib qw(t/lib); +use DBICTest; +use DBICTest::HelperRels; + +require "t/run/26positioned.tl"; +run_tests(DBICTest->schema); diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index f4c6706..996f53c 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -3,7 +3,7 @@ package # hide from PAUSE use base 'DBIx::Class::Core'; -__PACKAGE__->load_components('PK::Auto'); +__PACKAGE__->load_components('Positioned','PK::Auto'); DBICTest::Schema::Artist->table('artist'); DBICTest::Schema::Artist->add_columns( @@ -16,12 +16,17 @@ DBICTest::Schema::Artist->add_columns( size => 100, is_nullable => 1, }, + position => { + data_type => 'integer', + }, ); DBICTest::Schema::Artist->set_primary_key('artistid'); +__PACKAGE__->position_column('position'); __PACKAGE__->mk_classdata('field_name_for', { artistid => 'primary key', name => 'artist name', + position => 'list position', }); 1; diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 391de14..7dde18e 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -35,7 +35,8 @@ CREATE TABLE liner_notes ( -- CREATE TABLE artist ( artistid INTEGER PRIMARY KEY NOT NULL, - name varchar + name varchar, + position INTEGER ); -- diff --git a/t/run/04db.tl b/t/run/04db.tl index 424948c..2c91ed8 100644 --- a/t/run/04db.tl +++ b/t/run/04db.tl @@ -39,7 +39,12 @@ my $test_type_info = { 'data_type' => 'varchar', 'is_nullable' => 0, 'size' => undef, - } + }, + 'position' => { + 'data_type' => 'INTEGER', + 'is_nullable' => 0, + 'size' => undef, + }, }; is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); diff --git a/t/run/26positioned.tl b/t/run/26positioned.tl new file mode 100644 index 0000000..8981ca1 --- /dev/null +++ b/t/run/26positioned.tl @@ -0,0 +1,17 @@ +# vim: filetype=perl + +sub run_tests { + + my $schema = shift; + my $artists = $schema->resultset("Artist")->search({},{order_by=>'position'}); + + plan tests => $artists->count(); + + my $expected_position = 0; + while (my $artist = $artists->next()) { + $expected_position ++; + ok( ($artist->position()==$expected_position), 'default positions set as expected' ); + } +} + +1;