You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
# Before `make install' is performed this script should be runnable with
|
|
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t'
|
|
|
|
#########################
|
|
|
|
# change 'tests => 1' to 'tests => last_test_to_print';
|
|
|
|
use strict;
|
|
use Test::More;
|
|
BEGIN { use_ok('Lemonldap::NG::Common::Conf') }
|
|
|
|
#########################
|
|
|
|
# Insert your test code below, the Test::More module is use()ed here so read
|
|
# its man page ( perldoc Test::More ) for help writing this test script.
|
|
|
|
my $h;
|
|
|
|
ok(
|
|
$h = new Lemonldap::NG::Common::Conf(
|
|
{
|
|
type => 'File',
|
|
dirName => "t/",
|
|
}
|
|
),
|
|
'type => file',
|
|
);
|
|
my $count = 2;
|
|
|
|
my @test = (
|
|
|
|
# simple ascii
|
|
{ cfgNum => 1, test => 'ascii' },
|
|
|
|
# utf-8
|
|
{ cfgNum => 1, test => 'Русский' },
|
|
|
|
# compatible utf8/latin-1 char but with different codes
|
|
{ cfgNum => 1, test => 'éà' }
|
|
);
|
|
|
|
for ( my $i = 0 ; $i < @test ; $i++ ) {
|
|
ok( $h->store( $test[$i] ) == 1, "Test $i is stored" )
|
|
or print STDERR "$Lemonldap::NG::Common::Conf::msg $!";
|
|
$count++;
|
|
if ( -x '/usr/bin/file' ) {
|
|
eval {
|
|
open F, 'file t/lmConf-1.json |';
|
|
$_ = join( '', <F> );
|
|
close F;
|
|
ok( /(ascii|utf-?8)/si, "File is $1 encoded" )
|
|
or print STDERR "Result: $_\n";
|
|
$count++;
|
|
};
|
|
}
|
|
my $cfg;
|
|
ok( $cfg = $h->load(1), "Test $i can be read" )
|
|
or print STDERR $Lemonldap::NG::Common::Conf::msg;
|
|
ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" )
|
|
or print STDERR "Expect $cfg->{test} eq $test[$i]->{test}\n";
|
|
$count += 2;
|
|
}
|
|
|
|
unlink 't/lmConf-1.json';
|
|
|
|
done_testing($count);
|
|
|