File: approx_config.t

package info (click to toggle)
libconfig-model-approx-perl 1.011-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 156 kB
  • sloc: perl: 214; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,587 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
66
67
68
69
# -*- cperl -*-

use lib 'lib';

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

use warnings;
use strict;

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

# pseudo root where config files are written by config-model
my $wr_root = setup_test_dir;

my @orig = <DATA> ;

my $approx_dir = $wr_root->child('/etc/approx/');
$approx_dir->mkpath;
my $approx_conf = $approx_dir->child('approx.conf');
$approx_conf->spew(@orig);

my $inst = $model->instance (
    root_class_name   => 'Approx',
    instance_name     => 'approx_instance',
    root_dir          => $wr_root,
);

ok($inst,"Read $approx_conf and created instance") ;

my $cfg = $inst -> config_root ;

my $dump =  $cfg->dump_tree ();
print $dump if $trace ;

my $expect = q(max_rate=100K
verbose=1#"old style parameter (before approx 2.9.0)"
distributions:debian=http://ftp.debian.org/debian
distributions:local=file:///my/local/repo
distributions:security=http://security.debian.org/debian-security#"let's be secure" -
);

is ($dump,$expect,"check data read from approx.conf") ;

$cfg->load("max_rate=200K") ;

$inst->write_back ;

my $approxlines = $approx_conf->slurp;

like($approxlines,qr/200K/,"checked written approx file") ;
like($approxlines,qr/\$verbose/,"new approx file contains new style param") ;

done_testing;

__END__


$max_rate 100K

# old style parameter (before approx 2.9.0)
verbose  1

debian          http://ftp.debian.org/debian
# let's be secure
security        http://security.debian.org/debian-security
local           file:///my/local/repo