File: 06_config_api.t

package info (click to toggle)
libdancer-perl 1.3202%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,408 kB
  • ctags: 638
  • sloc: perl: 7,215; xml: 1,977; sh: 51; makefile: 29; sql: 5
file content (35 lines) | stat: -rw-r--r-- 804 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
31
32
33
34
35
use strict;
use warnings;
use Test::More import => ['!pass'];

use Dancer::Config;

plan skip_all => "YAML needed to run this tests"
    unless Dancer::ModuleLoader->load('YAML');

plan skip_all => "File::Temp 0.22 required"
    unless Dancer::ModuleLoader->load( 'File::Temp', '0.22' );

plan tests => 2;

eval {
    Dancer::Config::load_settings_from_yaml('foo');
};

like $@, qr/Unable to parse the configuration file/, 'non-existent yaml file';

my $dir = File::Temp::tempdir(CLEANUP => 1, TMPDIR => 1);

my $config_file = File::Spec->catfile($dir, 'settings.yml');

open my $fh, '>', $config_file;
print $fh '---"foo';
close $fh;

eval {
    Dancer::Config::load_settings_from_yaml($config_file);
};

like $@, qr/Unable to parse the configuration file/, 'invalid yaml file';

File::Temp::cleanup();