Commit | Line | Data |
a96520dd |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use lib 't/lib'; |
7 | use lib '../t/lib'; |
8 | |
9 | BEGIN { |
10 | use Test::More; |
11 | |
12 | eval "use YAML::Syck ()"; |
13 | if($@) { |
14 | eval "use YAML ()"; |
15 | if($@) { |
16 | plan skip_all => "YAML or YAML::Syck required for this test"; |
17 | } |
18 | } |
19 | |
b80c2ec1 |
20 | plan tests => 7; |
a96520dd |
21 | |
22 | use_ok('MXDefaultConfigTest'); |
b80c2ec1 |
23 | use_ok('MXDefaultWithSubConfigTest'); |
a96520dd |
24 | } |
25 | |
26 | # Can it load a simple YAML file with the options |
27 | # based on a default in the configfile attr |
28 | { |
29 | open(my $test_yaml, '>', 'test.yaml') |
30 | or die "Cannot create test.yaml: $!"; |
31 | print $test_yaml "direct_attr: 123\ninherited_ro_attr: asdf\nreq_attr: foo\n"; |
32 | close($test_yaml); |
33 | |
34 | my $foo = eval { |
35 | MXDefaultConfigTest->new_with_config(); |
36 | }; |
37 | ok(!$@, 'Did not die with good YAML configfile') |
38 | or diag $@; |
39 | |
40 | is($foo->req_attr, 'foo', 'req_attr works'); |
41 | is($foo->direct_attr, 123, 'direct_attr works'); |
42 | is($foo->inherited_ro_attr, 'asdf', 'inherited_ro_attr works'); |
b80c2ec1 |
43 | |
44 | $foo = eval { |
45 | MXDefaultWithSubConfigTest->new_with_config(); |
46 | }; |
47 | ok(!$@, 'Did not die with good YAML configfile') |
48 | or diag $@; |
a96520dd |
49 | } |
50 | |
51 | END { unlink('test.yaml') } |