Created
October 18, 2011 21:20
-
-
Save stevan/1296762 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Test::More; | |
use Test::Fatal; | |
use Test::Moose; | |
BEGIN { | |
use_ok('Jackalope'); | |
} | |
my $repo = Jackalope->new->resolve( type => 'Jackalope::Schema::Repository' ); | |
isa_ok($repo, 'Jackalope::Schema::Repository'); | |
is(exception{ | |
$repo->register_schemas([ | |
{ | |
id => 'my/role/one', | |
type => 'schema', | |
properties => { | |
a => { type => 'string' }, | |
b => { type => 'string' }, | |
}, | |
additional_properties => { | |
z => { type => 'number' }, | |
y => { type => 'number' } | |
} | |
}, | |
{ | |
id => 'my/role/two', | |
type => 'schema', | |
properties => { | |
c => { type => 'string' }, | |
d => { type => 'string' }, | |
}, | |
additional_properties => { | |
x => { type => 'number' } | |
} | |
} | |
]) | |
}, undef, '... did not die when registering this schema'); | |
is(exception{ | |
$repo->register_schema( | |
{ | |
id => 'my/schema', | |
type => 'schema', | |
with => [ { __ref__ => 'my/role/one' }, { __ref__ => 'my/role/two' } ], | |
properties => { | |
b => { type => 'number' }, | |
c => { type => 'number' }, | |
}, | |
additional_properties => { | |
y => { type => 'string' } | |
} | |
} | |
) | |
}, undef, '... did not die when registering this schema'); | |
my $schema = $repo->get_compiled_schema_by_uri('my/schema'); | |
is_deeply( | |
$schema->compiled, | |
{ | |
id => 'my/schema', | |
type => 'schema', | |
properties => { | |
a => { type => 'string' }, | |
b => { type => 'number' }, | |
c => { type => 'number' }, | |
d => { type => 'string' }, | |
}, | |
additional_properties => { | |
x => { type => 'number' }, | |
y => { type => 'string' }, | |
z => { type => 'number' }, | |
} | |
}, | |
'... got the correctly compiled schema' | |
); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment