8 use Path::Class qw/file/;
10 my $schema = DBICTest->init_schema();
14 my $rs = $schema->resultset('FileColumn');
15 my $source_file = file(__FILE__);
16 my $fname = $source_file->basename;
17 my $fh = $source_file->open('r') or die "failed to open $source_file: $!\n";
19 $rs->create({ file => { handle => $fh, filename => $fname } })
21 is ( $@, '', 'created' );
26 $fc->column_info('file')->{file_column_path},
28 $fc->file->{filename},
30 ok ( -e $storage, 'storage exists' );
33 $fc = $rs->find({ id => $fc->id });
35 is ( $fc->file->{filename}, $fname, 'filename matches' );
36 ok ( compare($storage, $source_file) == 0, 'file contents matches' );
39 my $new_fname = 'File.pm';
40 my $new_source_file = file(qw/lib DBIx Class InflateColumn File.pm/);
41 my $new_storage = file(
42 $fc->column_info('file')->{file_column_path},
46 $fh = $new_source_file->open('r') or die "failed to open $new_source_file: $!\n";
48 $fc->file({ handle => $fh, filename => $new_fname });
52 local $TODO = 'design change required';
53 ok ( ! -e $storage, 'old storage does not exist' );
56 ok ( -e $new_storage, 'new storage exists' );
59 $fc = $rs->find({ id => $fc->id });
61 is ( $fc->file->{filename}, $new_fname, 'new filname matches' );
62 ok ( compare($new_storage, $new_source_file) == 0, 'new content matches' );
66 ok ( ! -e $storage, 'storage deleted' );
68 $fh = $source_file->openr or die "failed to open $source_file: $!\n";
69 $fc = $rs->create({ file => { handle => $fh, filename => $fname } });
75 $fc->column_info('file')->{file_column_path},
77 $fc->file->{filename},
81 local $TODO = 'need resultset delete override to delete_all';
83 ok ( ! -e $storage, 'storage does not exist after $rs->delete' );