File: invalid-ref.t

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

eval { JSON::Validator->new->schema('data://main/spec.json') };
like $@, qr{Unable to resolve .*/definitions/Pet"}, 'missing definition';

my $workdir = path(__FILE__)->dirname;
eval { JSON::Validator->new->schema(path($workdir, 'spec', 'missing-ref.json')); };

ok $@, 'loading missing ref failed';
like $@, qr{Unable to load schema.*missing\.json}, 'error message' unless $^O eq 'MSWin32';

done_testing;

__DATA__
@@ spec.json
{
  "schema": {
    "type": "array",
    "items": { "$ref": "#/definitions/Pet" }
  }
}