diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-26 15:05:30 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-08-26 15:05:30 +0100 |
commit | 0e45fa27e4bc857f61b71f6c121a61e08e54cb6a (patch) | |
tree | 7e83c50825819b60a9a73f16c4d4f0a4ff247650 /t/open311/endpoint/schema.t | |
parent | c1178ea85d1879d6533ac09e2a3c813441554b43 (diff) | |
parent | a09c61c807d8d6b50227c9d8aa687f1eb22bad00 (diff) |
Merge branch 'stevenage-open311'
Diffstat (limited to 't/open311/endpoint/schema.t')
-rw-r--r-- | t/open311/endpoint/schema.t | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/t/open311/endpoint/schema.t b/t/open311/endpoint/schema.t deleted file mode 100644 index b669ca4a5..000000000 --- a/t/open311/endpoint/schema.t +++ /dev/null @@ -1,82 +0,0 @@ -use strict; use warnings; - -use Test::More; -use Test::Exception; - -use Data::Rx; -use Open311::Endpoint; - -my $endpoint = Open311::Endpoint->new; -my $schema = $endpoint->rx; - -subtest 'comma tests' => sub { - - dies_ok { - my $comma = $schema->make_schema({ - type => '/open311/comma', - }); - } 'Construction dies on no contents'; - - dies_ok { - my $comma = $schema->make_schema({ - type => '/open311/comma', - contents => '/open311/status', - zirble => 'fleem', - }); - } 'Construction dies on extra arguments'; - - my $comma = $schema->make_schema({ - type => '/open311/comma', - contents => '/open311/status', - trim => 1, - }); - - ok ! $comma->check( undef ), 'Undef is not a valid string'; - ok ! $comma->check( [] ), 'Reference is not a valid string'; - - ok ! $comma->check( 'zibble' ), 'invalid string'; - ok ! $comma->check( 'open,zibble' ), 'an invalid element'; - - ok $comma->check( 'open' ), 'single value'; - ok $comma->check( 'open,closed' ), 'multiple values ok'; - ok $comma->check( 'open, closed ' ), 'spaces trimmed ok'; -}; - -subtest 'datetime tests' => sub { - - dies_ok { - my $comma = $schema->make_schema({ - type => '/open311/datetime', - zirble => 'fleem', - }); - } 'Construction dies on extra keys'; - - my $dt = $schema->make_schema({ - type => '/open311/datetime', - }); - - ok ! $dt->check( undef ), 'Undef is not a valid string'; - ok ! $dt->check( [] ), 'Reference is not a valid string'; - - ok ! $dt->check( '9th Feb 2012' ), 'invalid datetime format'; - - ok $dt->check( '1994-11-05T08:15:30-05:00' ), 'datetime format with offset'; - ok $dt->check( '1994-11-05T08:15:30+05:00' ), 'datetime format with positive'; - ok $dt->check( '1994-11-05T13:15:30Z' ), 'datetime format zulu'; -}; - -subtest 'identifier tests' => sub { - my $id = $schema->make_schema( '/open311/example/identifier' ); - - ok ! $id->check( undef ), 'Undef is not a valid string'; - ok ! $id->check( '' ), 'Empty string is not a valid identifier'; - ok ! $id->check( 'foo bar' ), 'String with spaces is not a valid identifier'; - - ok $id->check( 'foo' ), 'Ascii word string is a valid identifier'; - ok $id->check( 'foo_bar' ), 'Ascii word string is a valid identifier'; - ok $id->check( 'foo_123' ), 'Ascii word/num string is a valid identifier'; -}; - -done_testing; - -1; |