lemonldap-ng/lemonldap-ng-common/t/02-Common-Conf-File.t

56 lines
1.4 KiB
Perl
Raw Normal View History

# 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';
2016-01-09 20:22:31 +01:00
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;
2019-02-05 23:12:17 +01:00
ok(
2019-02-07 09:27:56 +01:00
$h = new Lemonldap::NG::Common::Conf( {
2019-02-05 23:12:17 +01:00
type => 'File',
2016-01-09 20:22:31 +01:00
dirName => "t/",
}
),
'type => file',
);
2016-01-09 20:22:31 +01:00
my $count = 2;
2016-01-09 20:22:31 +01:00
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 => 'éà' }
);
2019-02-05 23:12:17 +01:00
for ( my $i = 0 ; $i < @test ; $i++ ) {
2016-01-09 20:22:31 +01:00
ok( $h->store( $test[$i] ) == 1, "Test $i is stored" )
2019-02-05 23:12:17 +01:00
or print STDERR "$Lemonldap::NG::Common::Conf::msg $!";
2016-01-09 20:22:31 +01:00
$count++;
my $cfg;
ok( $cfg = $h->load(1), "Test $i can be read" )
2019-02-05 23:12:17 +01:00
or print STDERR $Lemonldap::NG::Common::Conf::msg;
2016-01-11 21:32:44 +01:00
ok( $cfg->{test} eq $test[$i]->{test}, "Test $i is restored" )
2019-02-05 23:12:17 +01:00
or print STDERR "Expect $cfg->{test} eq $test[$i]->{test}\n";
2016-01-09 20:22:31 +01:00
$count += 2;
}
unlink 't/lmConf-1.json';
2016-01-09 20:22:31 +01:00
done_testing($count);