# Copyright (c) 2009 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: RealmFile.bunit,v 1.4 2010/10/29 17:37:12 nagler Exp $ ShellUtil(); my($content) = random_string(); my($folder) = '/' . random_string(); my($file) = "$folder/$content"; req()->set_realm_and_user('fourem'); my($archive_folder) = "/Archived$folder"; my($archive_file) = "/Archived$file;1"; my($subfolder); [ [-input => \$content, create => $file] => not_die(), [delete_deep => $folder] => sub { assert_equals(0, model('RealmFile')->unsafe_load({path => $file})); return 1; }, [-force => delete_deep => $archive_folder] => sub { assert_equals( [], model('RealmFileList')->map_iterate( undef, {path_info => $archive_folder}), ); return 1; }, [qw(-realm site folder_sizes /Public/WikiData)] => sub { my(undef, $actual) = @_; b_die($actual->[0]) unless $subfolder = (${$actual->[0]} =~ /(\d+) TOTAL/)[0]; return 1; }, [qw(-realm site folder_sizes)] => sub { my(undef, $actual) = @_; b_die($subfolder, ': not less than ', $actual->[0]) unless $subfolder < (${$actual->[0]} =~ /(\d+) TOTAL/)[0]; return 1; }, inline_case(sub {IO_File()->rm_rf(IO_File()->absolute_path('RealmFile.tmp'))}), [qw(backup_realms RealmFile.tmp site)] => sub { my($files) = [glob('RealmFile.tmp/*/*')]; assert_equals(1, scalar(@$files), "@$files"); $files = [`tar tzf $files->[0]`]; assert_not_equals(0, scalar(@$files), "@$files"); return 1; }, ];