X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Finflate%2Ffile_column.t;h=1b69e51de8ddc7094cbbcaa6fe2773cc59c4ead0;hb=8548e45cbaa8d8862ca78f675c73398ec2b0dc1d;hp=4de177a8d3d7e065535d3eb990a6a789a1e4a389;hpb=3814fdaddf1c49d2a8055c6da60cd93a1b513ad7;p=dbsrgits%2FDBIx-Class.git diff --git a/t/inflate/file_column.t b/t/inflate/file_column.t index 4de177a..1b69e51 100644 --- a/t/inflate/file_column.t +++ b/t/inflate/file_column.t @@ -3,19 +3,54 @@ use warnings; use Test::More; use lib qw(t/lib); + + use DBICTest; use DBICTest::Schema; use File::Compare; use Path::Class qw/file/; -$ENV{DBIC_IC_FILE_NOWARN} = 1; +{ + local $ENV{DBIC_IC_FILE_NOWARN} = 1; + + package DBICTest::Schema::FileColumn; + + use strict; + use warnings; + use base qw/DBICTest::BaseResult/; + + use File::Temp qw/tempdir/; -DBICTest::Schema->load_classes ('FileColumn'); -my $schema = DBICTest::Schema->connect(DBICTest->_database); -DBICTest->deploy_schema ($schema); + __PACKAGE__->load_components (qw/InflateColumn::File/); + __PACKAGE__->table('file_columns'); + + __PACKAGE__->add_columns( + id => { data_type => 'integer', is_auto_increment => 1 }, + file => { + data_type => 'varchar', + is_file_column => 1, + file_column_path => tempdir(CLEANUP => 1), + size => 255 + } + ); + + __PACKAGE__->set_primary_key('id'); +} +DBICTest::Schema->load_classes('FileColumn'); + +my $schema = DBICTest->init_schema; plan tests => 10; +if (not $ENV{DBICTEST_SQLT_DEPLOY}) { + $schema->storage->dbh->do(<<'EOF'); + CREATE TABLE file_columns ( + id INTEGER PRIMARY KEY, + file VARCHAR(255) + ) +EOF +} + my $rs = $schema->resultset('FileColumn'); my $source_file = file(__FILE__); my $fname = $source_file->basename; @@ -53,7 +88,7 @@ $fh = $new_source_file->open('r') or die "failed to open $new_source_file: $!\n" $fc->file({ handle => $fh, filename => $new_fname }); $fc->update; -TODO: { +{ local $TODO = 'design change required'; ok ( ! -e $storage, 'old storage does not exist' ); }; @@ -66,6 +101,9 @@ $fc = $rs->find({ id => $fc->id }); is ( $fc->file->{filename}, $new_fname, 'new filname matches' ); ok ( compare($new_storage, $new_source_file) == 0, 'new content matches' ); +if ($^O eq 'MSWin32') { + close $fc->file->{handle}; # can't delete open files on Win32 +} $fc->delete; ok ( ! -e $storage, 'storage deleted' ); @@ -82,8 +120,8 @@ $storage = file( $fc->file->{filename}, ); -TODO: { +{ local $TODO = 'need resultset delete override to delete_all'; $rs->delete; ok ( ! -e $storage, 'storage does not exist after $rs->delete' ); -}; +}