X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2F1-validate.t;h=5c8505086dba3ec648147425fd250f36c27f8859;hb=HEAD;hp=8b62d47c2f4e94323880b590e0b6650f90fd1afd;hpb=e1fc1194a5bd198e9464d59bc948a2cbaaa00e21;p=webpac2 diff --git a/t/1-validate.t b/t/1-validate.t index 8b62d47..5c85050 100755 --- a/t/1-validate.t +++ b/t/1-validate.t @@ -1,31 +1,22 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 54; -use Test::Exception; -use blib; +use lib 'lib'; -use Data::Dump qw/dump/; -use Cwd qw/abs_path/; +use Test::More tests => 56; BEGIN { +use_ok( 'WebPAC::Test' ); use_ok( 'WebPAC::Validate' ); } -my $debug = shift @ARGV; - -ok(my $abs_path = abs_path($0), "abs_path"); -$abs_path =~ s#/[^/]*$#/#; - -ok(my $v = new WebPAC::Validate( - debug => $debug, -), "new witout path"); +ok(my $v = new WebPAC::Validate(%LOG), "new witout path"); ok( ! $v->{rules}, 'no path' ); -ok(my $v = new WebPAC::Validate( +ok($v = new WebPAC::Validate( path => "$abs_path/data/validate_test", - debug => $debug, + %LOG, ), "new with path"); ok($v->{rules}, "rules exist"); @@ -37,6 +28,7 @@ is_deeply( $v->{rules}, { '903' => [ 'a', 'b', 'c' ], '904' => [ 'a' ], '905' => [ 'a*' ], + '906' => [ '0' ], }, 'simple rules parsed'); diag dump( $v ) if ( $debug ); @@ -60,6 +52,7 @@ is_deeply( $v->{rules}, { '903' => [ 'a', 'b', 'c' ], '904' => [ 'a' ], '905' => [ 'a*' ], + '906' => [ '0' ], }, 'rules'); ok($v->{rules}, "rules exist"); @@ -89,7 +82,7 @@ sub test_v { if (ref($tmp) eq 'HASH') { return $tmp; } else { - diag "explanation: $tmp"; + diag "explanation: $tmp" if $debug; } } } else { @@ -161,6 +154,14 @@ test_v({ '905' => [ ] }); +test_v({ + '906' => [ ] +}); + +test_v({ + '906' => [ { '0' => 'foo' } ] +}); + my $expected_error = { 900 => { not_repeatable => "probably bug in parsing input data" }, 901 => { missing_subfield => "a required", "dump" => "baz" },