"Fossies" - the Fresh Open Source Software Archive

Member "eprints3.4-3.4.4/ingredients/bazaar/tests/65_epm.pl" (7 Aug 2022, 2022 Bytes) of package /linux/www/eprints3.4-3.4.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "65_epm.pl": 3.4-3.4.3_vs_3.4-3.4.4.

    1 #!/usr/bin/perl
    2 
    3 use Test::More tests => 7;
    4 
    5 use strict;
    6 use warnings;
    7 
    8 BEGIN { use_ok( "EPrints" ); }
    9 BEGIN { use_ok( "EPrints::Test" ); }
   10 
   11 my $repo = EPrints::Test::get_test_repository();
   12 
   13 my $data = "Hello, World";
   14 my $base64 = MIME::Base64::encode_base64( $data );
   15 
   16 my $dataset = $repo->dataset( "epm" );
   17 
   18 my $tmpfile = File::Temp->new;
   19 syswrite($tmpfile, $data);
   20 sysseek($tmpfile, 0, 0);
   21 
   22 my $epm = $dataset->make_dataobj({
   23     version => '4.2.3',
   24     documents => [{
   25         content => "install",
   26         format => "other",
   27         main => "main.bin",
   28         files => [{
   29             _content => $tmpfile,
   30             filename => "main.bin",
   31             filesize => length($base64),
   32             mime_type => "application/octet-stream",
   33         }],
   34     }],
   35 });
   36 
   37 my $buffer;
   38 open(my $fh, ">", \$buffer) or die "Open scalar for writing: $!";
   39 $epm->serialise($fh, 1);
   40 ok($buffer =~ /$base64/, "serialise with files");
   41 
   42 $buffer = "";
   43 open($fh, ">", \$buffer);
   44 $epm->serialise($fh, 0);
   45 ok($buffer !~ /$base64/, "serialise without files");
   46 
   47 my $epm2 = $dataset->make_dataobj({
   48     version => '4.2.2',
   49 });
   50 ok($epm->version gt $epm2->version, "version gt");
   51 $epm2->set_value( "version", "4.2.4" );
   52 ok($epm->version lt $epm2->version, "version lt");
   53 
   54 ok(1);
   55 
   56 =head1 COPYRIGHT
   57 
   58 =for COPYRIGHT BEGIN
   59 
   60 Copyright 2022 University of Southampton.
   61 EPrints 3.4 is supplied by EPrints Services.
   62 
   63 http://www.eprints.org/eprints-3.4/
   64 
   65 =for COPYRIGHT END
   66 
   67 =for LICENSE BEGIN
   68 
   69 This file is part of EPrints 3.4 L<http://www.eprints.org/>.
   70 
   71 EPrints 3.4 and this file are released under the terms of the
   72 GNU Lesser General Public License version 3 as published by
   73 the Free Software Foundation unless otherwise stated.
   74 
   75 EPrints 3.4 is distributed in the hope that it will be useful,
   76 but WITHOUT ANY WARRANTY; without even the implied warranty of
   77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   78 See the GNU Lesser General Public License for more details.
   79 
   80 You should have received a copy of the GNU Lesser General Public
   81 License along with EPrints 3.4.
   82 If not, see L<http://www.gnu.org/licenses/>.
   83 
   84 =for LICENSE END
   85