1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
use strict;
use warnings
FATAL => qw( all ),
NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );
use Test::Expander;
use Test::Files::Constants qw( $FMT_CANNOT_GET_METADATA );
plan( 4 );
subtest 'got metadata cannot be acquired' => sub {
plan( 2 );
my $mock_this = mock $CLASS => (
override => [
diag => sub {
my ( $self, $messages ) = @_;
my $expected = sprintf( $FMT_CANNOT_GET_METADATA, 'got_archive', '.*' );
like( $messages->[ 0 ], qr/$expected/, 'exception raised' );
return $self;
}
]
);
my $self = $CLASS->_init->got( 'got_archive')->expected( 'reference_archive' )
->options( { META_DATA => sub { die} } );
isa_ok( $self->$METHOD, $CLASS );
};
subtest 'expected metadata cannot be acquired' => sub {
plan( 2 );
my $mock_this = mock $CLASS => (
override => [
diag => sub {
my ( $self, $messages ) = @_;
my $expected = sprintf( $FMT_CANNOT_GET_METADATA, 'reference_archive', '.*' );
like( $messages->[ 0 ], qr/$expected/, 'exception raised' );
return $self;
}
]
);
my $self = $CLASS->_init->got( 'got_archive')->expected( 'reference_archive' )
->options( { META_DATA => sub { die if shift eq 'reference_archive' } } );
isa_ok( $self->$METHOD, $CLASS );
};
subtest 'identical metadata' => sub {
plan( 2 );
my $self = $CLASS->_init->got( 'got_archive')->expected( 'reference_archive' )->options( { META_DATA => sub {} } );
isa_ok( $self->$METHOD, $CLASS );
is( $self->diag, [], 'no errors detected' );
};
subtest 'different metadata' => sub {
plan( 3 );
my $mock_this = mock $CLASS => ( override => [ is => sub ( $$;$@ ) { pass( 'differences displayed' ) } ] );
my $self = $CLASS->_init->got( 'got_archive')->expected( 'reference_archive' )
->options( { META_DATA => sub { shift } } );
isa_ok( $self->$METHOD, $CLASS );
is( $self->diag, undef, 'special handling provided' );
};
|