/[webpac2]/trunk/t/1-validate.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/1-validate.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 670 by dpavlin, Mon Sep 11 14:29:08 2006 UTC revision 858 by dpavlin, Sun May 27 17:09:47 2007 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use strict;  use strict;
4  use Test::More tests => 47;  use Test::More tests => 51;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 17  my $debug = shift @ARGV; Line 17  my $debug = shift @ARGV;
17  ok(my $abs_path = abs_path($0), "abs_path");  ok(my $abs_path = abs_path($0), "abs_path");
18  $abs_path =~ s#/[^/]*$#/#;  $abs_path =~ s#/[^/]*$#/#;
19    
 throws_ok { new WebPAC::Validate( no_log => 1 ) } qr/need path/, "new without path";  
   
20  ok(my $v = new WebPAC::Validate(  ok(my $v = new WebPAC::Validate(
21          path => "$abs_path/data/validate_test",          path => "$abs_path/data/validate_test_simple",
22            debug => $debug,
23    ), "new with path");
24    
25    ok($v->{rules}, "rules exist");
26    
27    is_deeply( $v->{rules}, {
28            '900' => [ 'a', 'b', 'c', 'd' ],
29    }, 'simple rules parsed');
30    
31    ok($v = new WebPAC::Validate(
32          debug => $debug,          debug => $debug,
33  ), "new");  ), "new witout path");
34    
35    ok( ! $v->{rules}, 'no path' );
36    
37    ok( $v->read_validate_file( "$abs_path/data/validate_test" ), "read_validate_file" );
38    
39  ok($v->{rules}, "rules exist");  ok($v->{rules}, "rules exist");
40    
# Line 36  is_deeply( $v->{rules}, { Line 48  is_deeply( $v->{rules}, {
48  }, 'rules parsed');  }, 'rules parsed');
49    
50    
51    throws_ok { $v->validate_rec() } qr/rec/, "validate_rec need rec";
 throws_ok { $v->validate_errors() } qr/rec/, "validate_rec need rec";  
52    
53  sub test_v {  sub test_v {
54          my $row = shift || die "no row?";          my $row = shift || die "no row?";
# Line 46  sub test_v { Line 57  sub test_v {
57    
58          $row->{'000'} = [ 42 ];          $row->{'000'} = [ 42 ];
59    
60          $v->reset_errors;          $v->reset;
61          my $e = $v->validate_errors( $row );          my $e = $v->validate_rec( $row );
62    
63          diag "validate $d\n",dump($e) if ($debug);          diag "validate $d\n",dump($e) if ($debug);
64    

Legend:
Removed from v.670  
changed lines
  Added in v.858

  ViewVC Help
Powered by ViewVC 1.1.26