File: configfile.t

package info (click to toggle)
libmoosex-app-cmd-perl 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 372 kB
  • sloc: perl: 366; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More;
use Moose;

BEGIN {
    eval 'require MooseX::ConfigFromFile; require YAML;';
    if ($@) {
        plan skip_all =>
            'These tests require MooseX::ConfigFromFile and YAML';
    }
    else {
        plan tests => 3;
    }
}

use lib 't/lib';
use Test::ConfigFromFile;

my $cmd = Test::ConfigFromFile->new;

{
    local @ARGV = qw(moo);
    eval { $cmd->run };

    like(
        $@,
        qr/Mandatory parameter 'moo' missing in call to ["(]eval[)"]/,
        'command died with the correct string',
    );
}

{
    local @ARGV = qw(moo --configfile=t/lib/Test/ConfigFromFile/config.yaml);
    eval { $cmd->run };

    like(
        $@,
        qr/cows go moo1 moo2 moo3/,
        'command died with the correct string',
    );
}

{
    local @ARGV = qw(boo);
    eval { $cmd->run };

    like( $@, qr/ghosts go moo1 moo2 moo3/, 'default configfile read', );
}