2019-07-01 16:16:12 +02:00
|
|
|
my $tests;
|
|
|
|
|
|
|
|
BEGIN { $tests = 5 }
|
|
|
|
|
|
|
|
use Test::More tests => $tests;
|
|
|
|
use JSON;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use_ok('Lemonldap::NG::Common::Cli');
|
|
|
|
use_ok('Lemonldap::NG::Manager::Cli');
|
2019-07-01 16:47:43 +02:00
|
|
|
&cleanConfFiles;
|
2019-07-01 16:16:12 +02:00
|
|
|
|
|
|
|
SKIP: {
|
2019-07-01 16:19:54 +02:00
|
|
|
eval 'use Test::Output;';
|
2019-07-01 16:16:12 +02:00
|
|
|
if ($@) {
|
2019-07-01 16:19:54 +02:00
|
|
|
skip 'Test::Output is missing, skipping', $tests - 2;
|
2019-07-01 16:16:12 +02:00
|
|
|
}
|
|
|
|
my @cmd;
|
|
|
|
@cmd = ('save');
|
|
|
|
my $client =
|
|
|
|
Lemonldap::NG::Manager::Cli->new( iniFile => 't/lemonldap-ng.ini' );
|
|
|
|
my $res = Capture::Tiny::capture_stdout( sub { $client->run(@cmd) } );
|
|
|
|
ok( $res =~ /^\s*(\{.*\})\s*$/s, '"save" result looks like JSON' );
|
|
|
|
eval { JSON::from_json($res) };
|
|
|
|
ok( not($@), ' result is JSON' ) or diag "error: $@";
|
|
|
|
close STDIN;
|
|
|
|
open STDIN, '<', \$res;
|
|
|
|
@cmd = ( 'restore', '-' );
|
|
|
|
Test::Output::combined_like( sub { $client->run(@cmd) },
|
|
|
|
qr/"cfgNum"\s*:\s*"2"/s, 'New config: 2' );
|
|
|
|
}
|
2019-07-01 16:47:43 +02:00
|
|
|
&cleanConfFiles;
|
2019-07-01 16:16:12 +02:00
|
|
|
|
2019-07-01 16:47:43 +02:00
|
|
|
sub cleanConfFiles {
|
|
|
|
foreach ( 2 .. $tests - 3 ) {
|
|
|
|
unlink "t/conf/lmConf-$_.json";
|
|
|
|
}
|
|
|
|
}
|