File: find_ok.t

package info (click to toggle)
libtest-files-perl 0.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: perl: 406; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 828 bytes parent folder | download
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
use strict;
use warnings
  FATAL    => qw( all ),
  NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );

use Test::Expander -tempdir => {};

use Test::Files::Constants qw( $DIRECTORY_OPTIONS $FMT_SUB_FAILED );

my $diag;
my $sub      = sub { path( shift )->basename eq 'GOOD' };
my $mockThis = mock $CLASS => (
  override => [
    _show_failure  => sub {},
    _show_result   => sub { 1 },
    _validate_args => sub { my $self = shift; $self->diag( $diag ); $sub },
  ]
);

path( $TEMP_DIR )->child( 'SUBDIR' )->mkdir;
path( $TEMP_DIR )->child( 'BAD'  )->touch;
path( $TEMP_DIR )->child( 'GOOD' )->touch;

plan( 2 );

$diag = [];
ok(  $METHOD_REF->( $TEMP_DIR, $sub ), 'valid arguments' );

$diag = [ 'ERROR' ];
ok( !$METHOD_REF->( $TEMP_DIR, $sub ), 'invalid arguments' );