From: Anders Nor Berle Date: Tue, 12 May 2009 15:17:09 +0000 (+0000) Subject: Test for failing code related to many to many in MySQL X-Git-Tag: v0.08103~93 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74de7c2cf9d082bb457f26d299d45699b488f449;p=dbsrgits%2FDBIx-Class.git Test for failing code related to many to many in MySQL --- diff --git a/t/71mysql.t b/t/71mysql.t index 467b4d3..475dc0f 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Exception; use lib qw(t/lib); use DBICTest; use DBI::Const::GetInfoType; @@ -13,7 +14,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 10; +plan tests => 11; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); @@ -23,6 +24,18 @@ $dbh->do("DROP TABLE IF EXISTS artist;"); $dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10));"); +$dbh->do("DROP TABLE IF EXISTS cd;"); + +$dbh->do("CREATE TABLE cd (cdid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, artist INTEGER, title TEXT, year INTEGER, genreid INTEGER, single_track INTEGER);"); + +$dbh->do("DROP TABLE IF EXISTS producer;"); + +$dbh->do("CREATE TABLE producer (producerid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name TEXT);"); + +$dbh->do("DROP TABLE IF EXISTS cd_to_producer;"); + +$dbh->do("CREATE TABLE cd_to_producer (cd INTEGER,producer INTEGER);"); + #'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', ''); # This is in Core now, but it's here just to test that it doesn't break @@ -119,8 +132,13 @@ NULLINSEARCH: { => 'Nothing Found!'; } +my $cd = $schema->resultset ('CD')->create ({}); + +my $producer = $schema->resultset ('Producer')->create ({}); + +lives_ok { $cd->set_producers ([ $cd ]) } 'set_relationship doesnt die'; # clean up our mess END { #$dbh->do("DROP TABLE artist") if $dbh; -} \ No newline at end of file +}