Config-Model
view release on metacpan or search on metacpan
t/apply_fix.t view on Meta::CPAN
# -*- cperl -*-
use warnings;
use Test::More;
use Test::Memory::Cycle;
use Config::Model;
use Config::Model::Value;
use Config::Model::Tester::Setup qw/init_test/;
use Data::Dumper;
use Test::Log::Log4perl;
use Test::Differences;
use strict;
use 5.10.1;
Test::Log::Log4perl->ignore_priority("info");
my ($model, $trace) = init_test();
# minimal set up to get things working
$model->create_config_class(
name => "NodeFix",
element => [
'fix-gnu' => {
type => 'leaf',
value_type => 'uniline',
'warn_if_match' => {
'Debian GNU/Linux' => {
'msg' => 'deprecated in favor of Debian GNU',
'fix' => 's!Debian GNU/Linux!Debian GNU!g;'
},
},
},
'fix-long' => {
type => 'leaf',
value_type => 'uniline',
'warn_if_match' => {
'[^\\n]{10,}' => {
'msg' => 'Line too long',
'fix' => '$_ = substr $_,0,8;'
},
},
},
# test data deletion from Dpkg/Copyright Disclaimer
# using undef
disclaimer_fix_with_undef => {
type => 'leaf',
value_type => 'string',
warn_if_match => {
'dh-make-perl' => {
fix => '$_ = undef ;',
msg => 'Disclaimer contains dh-make-perl boilerplate'
}
}
},
# same test as above using _store method
disclaimer_fix_with_delete => {
type => 'leaf',
value_type => 'string',
warn_if_match => {
'dh-make-perl' => {
fix => '$self->store(undef) ;',
msg => 'Disclaimer contains dh-make-perl boilerplate'
}
}
},
'chained-fix' => {
type => 'leaf',
value_type => 'uniline',
'warn_if_match' => {
( run in 0.826 second using v1.01-cache-2.11-cpan-39bf76dae61 )