Skip to content

Commit

Permalink
added and exporting constants used in t/bunnies.t
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarin committed Jul 23, 2024
1 parent 8bf1f28 commit 6bf6213
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions t/lib/HTFeed/Test/SpecSupport.pm
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package HTFeed::Test::SpecSupport;

use warnings;
use strict;

use FindBin;
use lib "$FindBin::Bin/../lib";

# support for Test::Spec tests
use HTFeed;
use HTFeed::Test::Logger;

use HTFeed::Test::TempDirs;

use warnings;
use strict;
use Exporter 'import';

our @EXPORT_OK = qw(mock_zephir mock_clamav stage_volume);
our @EXPORT_OK = qw(mock_zephir mock_clamav stage_volume NO_WAIT RECV_WAIT);
use constant NO_WAIT => -1;
use constant RECV_WAIT => 500;

sub mock_zephir {
no warnings 'redefine';
*HTFeed::Volume::get_sources = sub {
return ( 'ht_test','ht_test','ht_test' );
};

# use faked-up marc in case it's missing
no warnings 'redefine';
*HTFeed::Volume::get_sources = sub {
return ( 'ht_test','ht_test','ht_test' );
};

*HTFeed::SourceMETS::_get_marc_from_zephir = sub {
my $self = shift;
my $marc_path = shift;
# use faked-up marc in case it's missing

open(my $fh, ">$marc_path") or die("Can't open $marc_path: $!");
*HTFeed::SourceMETS::_get_marc_from_zephir = sub {
my $self = shift;
my $marc_path = shift;

print $fh <<EOT;
open(my $fh, ">$marc_path") or die("Can't open $marc_path: $!");
print $fh <<EOT;
<?xml version="1.0" encoding="UTF-8"?>
<collection xmlns="http://www.loc.gov/MARC21/slim">
<record>
Expand All @@ -38,32 +38,35 @@ sub mock_zephir {
</collection>
EOT

close($fh);
close($fh);
};

};

use warnings 'redefine';
use warnings 'redefine';
}

sub mock_clamav {
use HTFeed::Test::MockClamAV;
use HTFeed::Test::MockClamAV;

return HTFeed::Test::MockClamAV->new();
return HTFeed::Test::MockClamAV->new();
}

sub stage_volume {
my $tmpdirs = shift;
my $namespace = shift;
my $objid = shift;

my $mets = $tmpdirs->test_home . "/fixtures/volumes/$objid.mets.xml";
my $zip = $tmpdirs->test_home . "/fixtures/volumes/$objid.zip";
system("cp $mets $tmpdirs->{ingest}");
mkdir("$tmpdirs->{zipfile}/$objid");
system("cp $zip $tmpdirs->{zipfile}/$objid");

my $volume = HTFeed::Volume->new(
namespace => $namespace,
objid => $objid,
packagetype => 'simple');
my $tmpdirs = shift;
my $namespace = shift;
my $objid = shift;

my $mets = $tmpdirs->test_home . "/fixtures/volumes/$objid.mets.xml";
my $zip = $tmpdirs->test_home . "/fixtures/volumes/$objid.zip";

system("cp $mets $tmpdirs->{ingest}");
mkdir("$tmpdirs->{zipfile}/$objid");
system("cp $zip $tmpdirs->{zipfile}/$objid");

my $volume = HTFeed::Volume->new(
namespace => $namespace,
objid => $objid,
packagetype => 'simple'
);
}

1;

0 comments on commit 6bf6213

Please sign in to comment.