From: Rafael Kitover Date: Thu, 23 Jul 2009 12:34:01 +0000 (+0000) Subject: add test X-Git-Tag: v0.08109~65^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=818ec409baa3cd8a520bb6164a83e9a90fb84674;p=dbsrgits%2FDBIx-Class.git add test --- diff --git a/t/746mssql.t b/t/746mssql.t index f5c0071..7400698 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -12,7 +12,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PA plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 27; +plan tests => 29; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); @@ -75,6 +75,30 @@ $it->next; is( $it->next->name, "Artist 2", "iterator->next ok" ); is( $it->next, undef, "next past end of resultset ok" ); +# test MONEY type +$schema->storage->dbh_do (sub { + my ($storage, $dbh) = @_; + eval { $dbh->do("DROP TABLE money_test") }; + $dbh->do(<<'SQL'); + +CREATE TABLE money_test ( + id INT IDENTITY PRIMARY KEY, + amount money +) + +SQL + +}); + +my $rs = $schema->resultset('Money'); + +my $row; +lives_ok { + $row = $rs->create({ amount => \'cast(100.00 as money)' }); +} 'inserted a money value'; + +is $rs->find($row->id)->amount, '100.00', 'money value round-trip'; + $schema->storage->dbh_do (sub { my ($storage, $dbh) = @_; eval { $dbh->do("DROP TABLE Owners") }; @@ -232,7 +256,11 @@ $schema->storage->_sql_maker->{name_sep} = '.'; # clean up our mess END { - my $dbh = eval { $schema->storage->_dbh }; - $dbh->do('DROP TABLE artist') if $dbh; + if (my $dbh = eval { $schema->storage->_dbh }) { + $dbh->do('DROP TABLE artist'); + $dbh->do('DROP TABLE money_test'); + $dbh->do('DROP TABLE Books'); + $dbh->do('DROP TABLE Owners'); + } } # vim:sw=2 sts=2 diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm index ab5b098..a3e4484 100644 --- a/t/lib/DBICTest/Schema.pm +++ b/t/lib/DBICTest/Schema.pm @@ -21,6 +21,7 @@ __PACKAGE__->load_classes(qw/ Year2000CDs Year1999CDs CustomSql + Money /, { 'DBICTest::Schema' => [qw/ LinerNotes diff --git a/t/lib/DBICTest/Schema/Money.pm b/t/lib/DBICTest/Schema/Money.pm new file mode 100644 index 0000000..f4586eb --- /dev/null +++ b/t/lib/DBICTest/Schema/Money.pm @@ -0,0 +1,21 @@ +package # hide from PAUSE + DBICTest::Schema::Money; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('money_test'); + +__PACKAGE__->add_columns( + 'id' => { + data_type => 'integer', + is_auto_increment => 1, + }, + 'amount' => { + data_type => 'money', + is_nullable => 1, + }, +); + +__PACKAGE__->set_primary_key('id'); + +1;