File: chown-chmod-nostrict.t

package info (click to toggle)
libtest-mockfile-perl 0.037-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: perl: 4,110; makefile: 7
file content (38 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

use strict;
use warnings;

use Test2::Bundle::Extended;
use Test2::Tools::Explain;
use Test2::Plugin::NoWarnings;
use Test2::Tools::Exception qw< dies >;
use Test::MockFile qw< nostrict >;
use Cwd ();

my $euid     = $>;
my $egid     = int $);
my $filename = __FILE__;
my $file     = Test::MockFile->file( $filename, 'whatevs' );

subtest(
    'Unmocked files and mixing unmocked and mocked files' => sub {
        my $mocked   = Cwd::getcwd() . "/$filename";
        my $unmocked = '/foo_DOES_NOT_EXIST.znxc';

        like(
            dies( sub { chown -1, -1, $filename, $unmocked } ),
            qr/^\QYou called chown() on a mix of mocked ($mocked) and unmocked files ($unmocked)\E/xms,
            'Even without strict mode, you cannot mix mocked and unmocked files (chown)',
        );

        like(
            dies( sub { chmod 0755, $filename, $unmocked } ),
            qr/^\QYou called chmod() on a mix of mocked ($mocked) and unmocked files ($unmocked) \E/xms,
            'Even without strict mode, you cannot mix mocked and unmocked files (chmod)',
        );
    }
);

done_testing();
exit;