File: deep-mixed-ref.t

package info (click to toggle)
libjson-validator-perl 3.06%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 616 kB
  • sloc: perl: 1,308; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 691 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use Mojo::Base -strict;
use Test::More;
use JSON::Validator;
use Mojo::File 'path';

my $workdir   = path(__FILE__)->dirname;
my $file      = path($workdir, 'spec', 'with-deep-mixed-ref.json');
my $validator = JSON::Validator->new(cache_paths => [])->schema($file);
my @errors    = $validator->validate(
  {age => 1, weight => {mass => 72, unit => 'kg'}, height => 100});
is int(@errors), 0, 'valid input';

use Mojolicious::Lite;
push @{app->static->paths}, $workdir;
$validator->ua(app->ua);
$validator->schema(
  app->ua->server->url->clone->path('/spec/with-relative-ref.json'));
@errors = $validator->validate({age => 'not a number'});
is int(@errors), 1, 'invalid age';

done_testing;