9 use Path::Class qw/file/;
11 $ENV{DBIC_IC_FILE_NOWARN} = 1;
13 DBICTest::Schema->load_classes ('FileColumn');
14 my $schema = DBICTest::Schema->connect(DBICTest->_database);
15 DBICTest->deploy_schema ($schema);
19 my $rs = $schema->resultset('FileColumn');
20 my $source_file = file(__FILE__);
21 my $fname = $source_file->basename;
22 my $fh = $source_file->open('r') or die "failed to open $source_file: $!\n";
24 $rs->create({ file => { handle => $fh, filename => $fname } })
26 is ( $@, '', 'created' );
31 $fc->column_info('file')->{file_column_path},
33 $fc->file->{filename},
35 ok ( -e $storage, 'storage exists' );
38 $fc = $rs->find({ id => $fc->id });
40 is ( $fc->file->{filename}, $fname, 'filename matches' );
41 ok ( compare($storage, $source_file) == 0, 'file contents matches' );
44 my $new_fname = 'File.pm';
45 my $new_source_file = file(qw/lib DBIx Class InflateColumn File.pm/);
46 my $new_storage = file(
47 $fc->column_info('file')->{file_column_path},
51 $fh = $new_source_file->open('r') or die "failed to open $new_source_file: $!\n";
53 $fc->file({ handle => $fh, filename => $new_fname });
57 local $TODO = 'design change required';
58 ok ( ! -e $storage, 'old storage does not exist' );
61 ok ( -e $new_storage, 'new storage exists' );
64 $fc = $rs->find({ id => $fc->id });
66 is ( $fc->file->{filename}, $new_fname, 'new filname matches' );
67 ok ( compare($new_storage, $new_source_file) == 0, 'new content matches' );
71 ok ( ! -e $storage, 'storage deleted' );
73 $fh = $source_file->openr or die "failed to open $source_file: $!\n";
74 $fc = $rs->create({ file => { handle => $fh, filename => $fname } });
80 $fc->column_info('file')->{file_column_path},
82 $fc->file->{filename},
86 local $TODO = 'need resultset delete override to delete_all';
88 ok ( ! -e $storage, 'storage does not exist after $rs->delete' );