File: backend-ini-test-conf.pl

package info (click to toggle)
libconfig-model-perl 2.155-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,172 kB
  • sloc: perl: 15,117; makefile: 19
file content (77 lines) | stat: -rw-r--r-- 1,885 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
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
66
67
68
69
70
71
72
73
74
75
76
77
use strict;
use warnings;

# test inifile backend

# create minimal model to test ini file backend.

# this class is used by MiniIni class below
my @config_classes = ({
    name    => 'IniTest::Class',
    element => [
        [qw/lista listb/] => {
            type  => 'list',
            cargo => {
                type       => 'leaf',
                value_type => 'uniline',
            },
        },
    ]
});

push @config_classes, {
    name => 'MiniIni',
        element => [
            [qw/foo bar/] => {
                type  => 'list',
                cargo => {
                    type       => 'leaf',
                    value_type => 'uniline',
                }
            },

            baz => {
                qw/type leaf value_type uniline/,
            },
            [qw/class1 class2/] => {
                type              => 'node',
                config_class_name => 'IniTest::Class'
            }
        ],
    rw_config => {
        backend     => 'IniFile',
        # specify where is the config file. this must match
        # the $conf_file_name and $conf_dir variable above
        config_dir  => '/etc/',
        file        => 'test.ini',
        file_mode   => 'a=r,ug+w',
        auto_create => 1,
    },
};


# the test suite
my @tests = (
    {   # test complex parameters
        name  => 'complex',
        check => [
            # check a specific value stored in example file
            baz => q!/bin/sh -c '[ "$(cat /etc/X11/default-display-manager 2>/dev/null)" = "/usr/bin/sddm" ]''!
        ],
        file_mode => {
            '/etc/test.ini' => oct(664)
        }
    },
);

return {
    # specify the name of the class to test
    model_to_test => "MiniIni",

    # specify where is the example file
    conf_file_name => 'test.ini',
    conf_dir => '/etc',

    config_classes => \@config_classes,
    tests => \@tests
};