File: backend_detect.t

package info (click to toggle)
libconfig-model-itself-perl 2.022-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 524 kB
  • sloc: perl: 3,491; makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,575 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
# -*- cperl -*-

use ExtUtils::testlib;
use Test::More ;
use Config::Model;
use Config::Model::Tester::Setup qw/init_test/;
use Test::Memory::Cycle;

use warnings;
use strict;

my ($model, $trace) = init_test();

$model ->create_config_class (
   name => "Master",
   'element' => [
       'backend' => {
           type => 'leaf',
           class => 'Config::Model::Itself::BackendDetector' ,
           value_type => 'enum',
           choice => [qw/cds_file perl_file ini_file custom/],

           help => {
               cds_file => "file ...",
               ini_file => "Ini file ...",
               perl_file => "file  perl",
               custom => "Custom format",
           }
       }
   ],
);

ok(1,"test class created") ;

my $root = $model->instance(root_class_name => 'Master') -> config_root ;

my $backend = $root->fetch_element('backend') ;

my @choices = $backend->get_choice ;

ok( (scalar grep { $_ eq 'IniFile'} @choices), "IniFile plugin backend was found") ;

SKIP: {
    skip "this help is available after Config::Model is built", 1 unless
        $Config::Model::VERSION < 3;
    # test break when using directly Config::Model repo because get_help
    # retrieves info from NAME section which is added at build time by
    # Pod::Weaver
    my $help = $backend->get_help('IniFile') ;
    like($help,qr/provided by L<Config::Model::Backend::IniFile>/,
         "Found IniFile doc in pod") ;
}

my $help = $backend->get_help('cds_file') ;
is($help,"file ...", "cds_file help was kept") ;

memory_cycle_ok($model, "memory cycle");

done_testing;