From: mikew Date: Fri, 11 Oct 2013 13:42:22 +0000 (-0400) Subject: - Add table Artist_UC to the test data X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ffix-test;p=dbsrgits%2FDBIx-Class-Fixtures.git - Add table Artist_UC to the test data - Add ResultSource Artist_UC_RS. This will test cases where resultsource name is not the same as the table name - Fix t/12-populate-basic.t to use $source->from instead of $source->name to find directory to load. dump uses ->from --- diff --git a/t/07-dump-all.t b/t/07-dump-all.t index 57b73d7..7617733 100644 --- a/t/07-dump-all.t +++ b/t/07-dump-all.t @@ -7,7 +7,7 @@ use DBICTest; use Path::Class; use Data::Dumper; -plan tests => 16; +plan tests => 18; # set up and populate schema ok(my $schema = DBICTest->init_schema( ), 'got schema'); diff --git a/t/12-populate-basic.t b/t/12-populate-basic.t index e37f490..c60be1c 100644 --- a/t/12-populate-basic.t +++ b/t/12-populate-basic.t @@ -38,7 +38,7 @@ foreach my $set ('simple', 'quantity', 'fetch', 'rules') { my $fixture_dir = dir('t/var/fixtures'); foreach my $class ($schema->sources) { - my $source_dir = dir($fixture_dir, lc($class)); + my $source_dir = dir($fixture_dir, lc $schema->source($class)->from); is($schema->resultset($class)->count, (-e $source_dir) ? scalar($source_dir->children) : 0, "correct number of $set " . lc($class) diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 988e02b..488e827 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -211,6 +211,15 @@ sub populate_schema { [ 17, 1, 2, "Apiary"], [ 18, 1, 3, "Beehind You"], ]); + + $schema->populate('Artist_UC_RS', [ + [ qw/artistid name/ ], + [ 1, 'Caterwauler McCrae' ], + [ 2, 'Random Boy Band' ], + [ 3, 'We Are Goth' ], + [ 4, '' ], # Test overridden new will default name to "Test Name" using use_create => 1. + [ 32948, 'Big PK' ], + ]); } 1; diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index 350eecc..69c5bee 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -4,7 +4,7 @@ package # hide from PAUSE use base qw/DBIx::Class::Schema/; no warnings qw/qw/; - -__PACKAGE__->load_classes(qw/Artist CD Track Tag Producer CD_to_Producer/); + +__PACKAGE__->load_classes(qw/Artist CD Track Tag Producer CD_to_Producer Artist_UC_RS/); 1; diff --git a/t/lib/DBICTest/Schema/Artist_UC_RS.pm b/t/lib/DBICTest/Schema/Artist_UC_RS.pm new file mode 100644 index 0000000..2549eae --- /dev/null +++ b/t/lib/DBICTest/Schema/Artist_UC_RS.pm @@ -0,0 +1,28 @@ +package # hide from PAUSE + DBICTest::Schema::Artist_UC_RS; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->table('Artist_UC'); +__PACKAGE__->add_columns( + 'artistid' => { + data_type => 'integer', + is_auto_increment => 1, + }, + 'name' => { + data_type => 'varchar', + size => 100, + is_nullable => 1, + }, +); +__PACKAGE__->set_primary_key('artistid'); + +sub new { + my ( $class, $args ) = @_; + + $args->{name} = "Test Name" unless $args->{name}; + + return $class->next::method( $args ); +} + +1; diff --git a/t/lib/mysql.sql b/t/lib/mysql.sql index ca1b034..d648b45 100644 --- a/t/lib/mysql.sql +++ b/t/lib/mysql.sql @@ -59,3 +59,11 @@ CREATE TABLE producer ( producerid INTEGER PRIMARY KEY NOT NULL, name varchar(100) NOT NULL ); + +-- +-- Table:: Artist_UC +-- +CREATE TABLE Artist_UC ( + artistid INTEGER PRIMARY KEY NOT NULL, + name varchar(100) +); diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 1e21627..b74a42a 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -60,4 +60,13 @@ CREATE TABLE producer ( name varchar(100) NOT NULL ); +-- +-- Table:: Artist_UC +-- +CREATE TABLE Artist_UC ( + artistid INTEGER PRIMARY KEY NOT NULL, + name varchar(100) +); + + COMMIT; diff --git a/t/var/configs/simple.json b/t/var/configs/simple.json index 44754a3..3be6439 100644 --- a/t/var/configs/simple.json +++ b/t/var/configs/simple.json @@ -8,5 +8,9 @@ "sets": [{ "class": "Artist", "quantity": 1 - }] -} \ No newline at end of file + }, + { + "class": "Artist_UC_RS", + "quantity": 2 + }] +}