Some testdb changes and alignment, preparing for test refactor branch
[dbsrgits/DBIx-Class.git] / t / bindtype_columns.t
index a32e24c..12df2dc 100644 (file)
@@ -7,37 +7,37 @@ use DBICTest;
 
 my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
 
-$dsn   = 'dbi:Pg:dbname=postgres;host=localhost' unless $dsn;
-$dbuser        = 'postgres' unless $dbuser;
-$dbpass        = 'postgres' unless $dbpass;
-
 plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $dbuser);
   
 plan tests => 3;
 
-DBICTest::Schema->compose_connection('PGTest' => $dsn, $dbuser, $dbpass);
-
-my $dbh = PGTest->schema->storage->dbh;
-
-$dbh->do(qq[
+my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
 
-       CREATE TABLE artist
-       (
-               artistid                serial  NOT NULL        PRIMARY KEY,
-               media                   bytea   NOT NULL,
-               name                    varchar NULL
-       );
-],{ RaiseError => 1, PrintError => 1 });
+my $dbh = $schema->storage->dbh;
 
+{
+    local $SIG{__WARN__} = sub {};
+    $dbh->do('DROP TABLE IF EXISTS artist');
+    $dbh->do(qq[
+        CREATE TABLE artist
+        (
+            artistid        serial       NOT NULL   PRIMARY KEY,
+            media           bytea        NOT NULL,
+            name            varchar(100) NULL,
+            rank            integer NOT  NULL       DEFAULT '13',
+            charfield       char(10)     NULL
+        );
+    ],{ RaiseError => 1, PrintError => 1 });
+}
 
-PGTest::Artist->load_components(qw/ 
+$schema->class('Artist')->load_components(qw/ 
 
        PK::Auto 
        Core 
 /);
 
-PGTest::Artist->add_columns(
+$schema->class('Artist')->add_columns(
        
        "media", { 
        
@@ -49,12 +49,12 @@ PGTest::Artist->add_columns(
 # test primary key handling
 my $big_long_string    = 'abcd' x 250000;
 
-my $new = PGTest::Artist->create({ media => $big_long_string });
+my $new = $schema->resultset('Artist')->create({ media => $big_long_string });
 
 ok($new->artistid, "Created a blob row");
 is($new->media,        $big_long_string, "Set the blob correctly.");
 
-my $rs = PGTest::Artist->find({artistid=>$new->artistid});
+my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid});
 
 is($rs->get_column('media'), $big_long_string, "Created the blob correctly.");