File: backend-yaml-data-test-conf.pl

package info (click to toggle)
libconfig-model-backend-yaml-perl 2.134-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 221; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,683 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# This file is part of Config-Model-Backend-Yaml
#
# This software is Copyright (c) 2018 by Dominique Dumont.
#
# This is free software, licensed under:
#
#   The GNU Lesser General Public License, Version 2.1, February 1999
#
use strict;
use warnings;
use utf8;

my @config_classes = ({
    name => 'Master',

    rw_config => {
        backend     => 'yaml',
        config_dir  => '/etc/',
        file        => 'test.yaml',
    },

    element => [
        true_bool  => { qw/type leaf value_type boolean upstream_default 0/},
        false_bool => { qw/type leaf value_type boolean upstream_default 0/},
        new_bool => { qw/type leaf value_type boolean upstream_default 0/},
        null_value => { qw/type leaf value_type uniline/},
        utf8_string => { qw/type leaf value_type uniline/},
    ]
});

my @tests = (
    {
        name  => 'basic',
        check => [
            # values are translated from whatever YAML lib returns to true and false
            true_bool => 1,
            false_bool => 0,
            null_value => undef
        ],
        load => 'new_bool=1',
        file_contents => {
            # test that file contains real booleans
            "/etc/test.yaml" => "---\nfalse_bool: false\nnew_bool: true\ntrue_bool: true\n",
        }
    },
    {
        name => 'utf8_data',
        check => [
            utf8_string => "Марцел Mézigue"
        ],
        file_contents_like => {
            "/etc/test.yaml" => [ qr/Марцел Mézigue/ ] ,
        }
    }
);

return {
    model_to_test => "Master",
    conf_dir => '/etc',
    conf_file_name => 'test.yaml',
    config_classes => \@config_classes,
    tests => \@tests
};