Add test to verify that parameters are uniq
This commit is contained in:
parent
e84e8b106d
commit
fcad402857
|
@ -13,6 +13,7 @@ lib/Lemonldap/NG/Manager/Cli.pm
|
|||
lib/Lemonldap/NG/Manager/Cli/Lib.pm
|
||||
lib/Lemonldap/NG/Manager/Conf.pm
|
||||
lib/Lemonldap/NG/Manager/Conf/Tests.pm
|
||||
lib/Lemonldap/NG/Manager/Conf/Zero.pm
|
||||
lib/Lemonldap/NG/Manager/ConfParser.pm
|
||||
lib/Lemonldap/NG/Manager/Constants.pm
|
||||
lib/Lemonldap/NG/Manager/Lib.pm
|
||||
|
@ -128,6 +129,7 @@ t/12-save-changed-conf.t
|
|||
t/20-test-coverage.t
|
||||
t/40-sessions.t
|
||||
t/50-notifications.t
|
||||
t/80-attributes.t
|
||||
t/90-translations.t
|
||||
t/99-pod.t
|
||||
t/conf/lmConf-1.js
|
||||
|
|
65
lemonldap-ng-manager/t/80-attributes.t
Normal file
65
lemonldap-ng-manager/t/80-attributes.t
Normal file
|
@ -0,0 +1,65 @@
|
|||
use strict;
|
||||
use Test::More;
|
||||
|
||||
ok( open( F, 'lib/Lemonldap/NG/Manager/Build/Attributes.pm' ),
|
||||
'open attributes file' );
|
||||
my $count = 1;
|
||||
|
||||
while ( <F> !~ /sub\s+attributes/ ) { 1 }
|
||||
|
||||
my %h;
|
||||
|
||||
while (<F>) {
|
||||
next unless /^\s{8}["']?(\w+)/;
|
||||
my $attr = $1;
|
||||
$h{$attr}++;
|
||||
ok( $h{$attr} == 1, "$attr is uniq" );
|
||||
$count++;
|
||||
}
|
||||
close F;
|
||||
|
||||
use_ok('Lemonldap::NG::Manager::Build::Tree');
|
||||
my $tree;
|
||||
ok( $tree = Lemonldap::NG::Manager::Build::Tree::tree(), 'Get tree' );
|
||||
$count += 2;
|
||||
|
||||
scanTree($tree);
|
||||
|
||||
done_testing($count);
|
||||
|
||||
my %h2;
|
||||
|
||||
sub scanTree {
|
||||
my $tree = shift;
|
||||
if ( ref $tree ) {
|
||||
ok( ref($tree) eq 'ARRAY', 'Tree is an array' );
|
||||
$count++;
|
||||
foreach my $leaf (@$tree) {
|
||||
if ( ref $leaf ) {
|
||||
my $name;
|
||||
ok( $name = $leaf->{title}, "Node has a name" );
|
||||
ok( $name =~ /^\w+$/, "Name is a string" );
|
||||
ok( ref($leaf) eq 'HASH' );
|
||||
ok(
|
||||
(
|
||||
exists( $leaf->{nodes} )
|
||||
or exists( $leaf->{nodes_cond} )
|
||||
or exists( $leaf->{group} )
|
||||
),
|
||||
"Node $name has leafs"
|
||||
);
|
||||
$count += 3;
|
||||
foreach my $n (qw(nodes nodes_cond group)) {
|
||||
scanTree( $leaf->{$n} ) if ( exists $leaf->{$n} );
|
||||
}
|
||||
}
|
||||
else {
|
||||
ok( $leaf =~ /^\*?\w+/, "Leaf is an attribute name ($leaf)" );
|
||||
$h2{$leaf}++;
|
||||
ok( $h2{$leaf} == 1, "$leaf is uniq" );
|
||||
$count += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user