# Copyright (c) 2008 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Parseable.bunit,v 1.3 2008/06/17 02:06:43 nagler Exp $ Request(); req()->set_realm('demo'); my($txt) = model(RealmFile => {path => '/Public/file.txt'}); [ [$txt] => [ get_os_path => $txt->get_os_path, get_content => sub {[$txt->get_content]}, get => [ path => $txt->get('path'), content_type => 'text/plain', ], as_string => 'Parseable[/Public/file.txt,text/plain]', ], [{ class => 'RealmFile', content => \('a,b'), content_type => 'text/csv', req => req(), }] => [ get_os_path => qr{/tmp/}, get_content => 'a,b', get => [ content_type => 'text/csv', ], as_string => 'Parseable[,text/csv]', ], class() => [ new => [ [{}] => DIE(), [{ class => 'RealmFile', content_type => 'text/plain', content => 'not ok', req => req(), }] => qr{is invalid type for content$}, ], sub { # cleanup tmp files req()->process_cleanup; return 1; } => 1, ], ];