7 # inject IC::File into the result baseclass for testing
9 $ENV{DBIC_IC_FILE_NOWARN} = 1;
10 require DBICTest::BaseResult;
11 DBICTest::BaseResult->load_components (qw/InflateColumn::File/);
17 use Path::Class qw/file/;
19 my $schema = DBICTest->init_schema;
23 my $rs = $schema->resultset('FileColumn');
24 my $source_file = file(__FILE__);
25 my $fname = $source_file->basename;
26 my $fh = $source_file->open('r') or die "failed to open $source_file: $!\n";
28 $rs->create({ file => { handle => $fh, filename => $fname } })
30 is ( $@, '', 'created' );
35 $fc->column_info('file')->{file_column_path},
37 $fc->file->{filename},
39 ok ( -e $storage, 'storage exists' );
42 $fc = $rs->find({ id => $fc->id });
44 is ( $fc->file->{filename}, $fname, 'filename matches' );
45 ok ( compare($storage, $source_file) == 0, 'file contents matches' );
48 my $new_fname = 'File.pm';
49 my $new_source_file = file(qw/lib DBIx Class InflateColumn File.pm/);
50 my $new_storage = file(
51 $fc->column_info('file')->{file_column_path},
55 $fh = $new_source_file->open('r') or die "failed to open $new_source_file: $!\n";
57 $fc->file({ handle => $fh, filename => $new_fname });
61 local $TODO = 'design change required';
62 ok ( ! -e $storage, 'old storage does not exist' );
65 ok ( -e $new_storage, 'new storage exists' );
68 $fc = $rs->find({ id => $fc->id });
70 is ( $fc->file->{filename}, $new_fname, 'new filname matches' );
71 ok ( compare($new_storage, $new_source_file) == 0, 'new content matches' );
75 ok ( ! -e $storage, 'storage deleted' );
77 $fh = $source_file->openr or die "failed to open $source_file: $!\n";
78 $fc = $rs->create({ file => { handle => $fh, filename => $fname } });
84 $fc->column_info('file')->{file_column_path},
86 $fc->file->{filename},
90 local $TODO = 'need resultset delete override to delete_all';
92 ok ( ! -e $storage, 'storage does not exist after $rs->delete' );