| 1 |
# Verify that bad changes are detected |
| 2 |
|
| 3 |
use warnings; |
| 4 |
use Test::More; |
| 5 |
use strict; |
| 6 |
use JSON; |
| 7 |
require 't/test-lib.pm'; |
| 8 |
|
| 9 |
my $struct = 't/jsonfiles/14-bad.json'; |
| 10 |
|
| 11 |
my ( $len, $body ) = substitute_io_handle($struct); |
| 12 |
|
| 13 |
my ( $res, $resBody ); |
| 14 |
ok( |
| 15 |
$res = |
| 16 |
&client->_post( '/confs/', 'cfgNum=1', $body, 'application/json', $len ), |
| 17 |
"Request succeed" |
| 18 |
); |
| 19 |
ok( $res->[0] == 200, "Result code is 200" ); |
| 20 |
ok( $resBody = from_json( $res->[2]->[0] ), "Result body contains JSON text" ); |
| 21 |
ok( $resBody->{result} == 0, "JSON response contains \"result:0\"" ) |
| 22 |
or print STDERR Dumper($res); |
| 23 |
ok( ( |
| 24 |
$resBody->{details}->{__errors__} |
| 25 |
and @{ $resBody->{details}->{__errors__} } == 1 |
| 26 |
), |
| 27 |
'1 error detected' |
| 28 |
) or print STDERR Dumper($resBody); |
| 29 |
|
| 30 |
count(5); |
| 31 |
|
| 32 |
done_testing( count() ); |
| 33 |
|
| 34 |
unlink "$main::tmpdir/conf/lmConf-2.json"; |