[Bast-commits] r7854 - in DBIx-Class-DynamicDefault/1.000/trunk: .
t t/lib
gshank at dev.catalyst.perl.org
gshank at dev.catalyst.perl.org
Wed Nov 11 19:36:13 GMT 2009
Author: gshank
Date: 2009-11-11 19:36:12 +0000 (Wed, 11 Nov 2009)
New Revision: 7854
Added:
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/DBICTest.pm
DBIx-Class-DynamicDefault/1.000/trunk/t/lib/sqlite.sql
Modified:
DBIx-Class-DynamicDefault/1.000/trunk/Makefile.PL
DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t
Log:
switch from DBICx::TestDatabase to using sql file to avoid SQL::Translator prereq
Modified: DBIx-Class-DynamicDefault/1.000/trunk/Makefile.PL
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/Makefile.PL 2009-11-10 19:21:38 UTC (rev 7853)
+++ DBIx-Class-DynamicDefault/1.000/trunk/Makefile.PL 2009-11-11 19:36:12 UTC (rev 7854)
@@ -8,8 +8,6 @@
requires 'DBIx::Class' => '0.08009';
requires 'parent';
-build_requires 'DBICx::TestDatabase';
-
makemaker_args(depend => { dist => 'README' });
auto_provides;
extra_tests;
Modified: DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t 2009-11-10 19:21:38 UTC (rev 7853)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/basic.t 2009-11-11 19:36:12 UTC (rev 7854)
@@ -7,8 +7,9 @@
use FindBin;
use lib "$FindBin::Bin/lib";
+use DBICTest;
-my $schema = DBICx::TestDatabase->new('TestSchema');
+my $schema = DBICTest->init_schema;
my $rs = $schema->resultset('Table');
my $rs2 = $schema->resultset('Affe');
Added: DBIx-Class-DynamicDefault/1.000/trunk/t/lib/DBICTest.pm
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/lib/DBICTest.pm (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/lib/DBICTest.pm 2009-11-11 19:36:12 UTC (rev 7854)
@@ -0,0 +1,71 @@
+package # hide from PAUSE
+ DBICTest;
+
+use strict;
+use warnings;
+use TestSchema;
+
+=head1 NAME
+
+DBICTest - Minimal version of DBICTest from the DBIx::Class dist
+
+=head1 SYNOPSIS
+
+ use lib qw(t/lib);
+ use DBICTest;
+ use Test::More;
+
+ my $schema = DBICTest->init_schema();
+
+=head1 DESCRIPTION
+
+This module provides the basic utilities to write tests against
+DBIx::Class.
+
+=head1 METHODS
+
+=head2 init_schema
+
+ my $schema = DBICTest->init_schema;
+
+=cut
+
+sub _connect_info {
+ my $self = shift;
+ my $db_file = ':memory:';
+
+ my $dsn = "dbi:SQLite:${db_file}";
+ my $dbuser = '';
+ my $dbpass = '';
+
+ my @connect_info = ( $dsn, $dbuser, $dbpass );
+
+ return @connect_info;
+}
+
+sub init_schema {
+ my $self = shift;
+
+ my $schema = TestSchema->connect( $self->_connect_info );
+ $self->deploy_schema($schema);
+ return $schema;
+}
+
+sub deploy_schema {
+ my $self = shift;
+ my $schema = shift;
+
+ open IN, "t/lib/sqlite.sql";
+ my $sql;
+ { local $/ = undef; $sql = <IN>; }
+ close IN;
+ for my $chunk ( split( /;\s*\n+/, $sql ) ) {
+ if ( $chunk =~ / ^ (?! --\s* ) \S /xm )
+ { # there is some real sql in the chunk - a non-space at the start of the string which is not a comment
+ $schema->storage->dbh_do( sub { $_[1]->do($chunk) } ) || warn "Error executing SQL. chunk: $chunk";
+ }
+ }
+ return;
+}
+
+1;
Added: DBIx-Class-DynamicDefault/1.000/trunk/t/lib/sqlite.sql
===================================================================
--- DBIx-Class-DynamicDefault/1.000/trunk/t/lib/sqlite.sql (rev 0)
+++ DBIx-Class-DynamicDefault/1.000/trunk/t/lib/sqlite.sql 2009-11-11 19:36:12 UTC (rev 7854)
@@ -0,0 +1,31 @@
+--
+-- Created by SQL::Translator::Producer::SQLite
+-- Created on Wed Nov 11 12:27:59 2009
+--
+
+
+BEGIN TRANSACTION;
+
+--
+-- Table: affe
+--
+
+CREATE TABLE affe (
+ moo INTEGER PRIMARY KEY NOT NULL,
+ kooh text NOT NULL,
+ baz integer NOT NULL,
+ bar integer NOT NULL
+);
+
+--
+-- Table: fubar
+--
+
+CREATE TABLE fubar (
+ quux INTEGER PRIMARY KEY NOT NULL,
+ garply integer,
+ foo integer NOT NULL,
+ fred text NOT NULL
+);
+
+COMMIT;
More information about the Bast-commits
mailing list