Pg-Blobs

 view release on metacpan or  search on metacpan

t/01-basics.t  view on Meta::CPAN

}

ok( my $o = My::Object->new({ dbh => $dbh }) , "Ok created o");
$dbh->begin_work();

ok( my $oid = $o->pgblobs_create_blob() , "Blob is created");
ok( $oid = $o->pgblobs_store_blob('BINARYCONTENT') , "Something is stored in blob");
ok( my $rc =  $o->pgblobs_fetch_blob($oid) , "Fetched content");
ok( $rc eq 'BINARYCONTENT' , "Same content was retrieved");
{
    ## A bit of cake streaming now
    my $nslices = 1000;
    my $cake;
    my $read = sub{
	unless( $nslices-- ){ return undef ;}
	my $slice =  int(rand(1000)) + 1 ;
	$cake .= $slice ;
	return $slice;
    };
    ok( my $other_oid = $o->pgblobs_stream_in_blob($read) , "Ok got other_oid");
    ok( my $other_cake = $o->pgblobs_fetch_blob($other_oid) , "Ok got other cake");



( run in 0.232 second using v1.01-cache-2.11-cpan-4d50c553e7e )