projects
/
perl-cwmp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r212@brr: dpavlin | 2007-11-14 20:23:06 +0100
[perl-cwmp.git]
/
t
/
10-request.t
diff --git
a/t/10-request.t
b/t/10-request.t
index
80243a7
..
03e9098
100755
(executable)
--- a/
t/10-request.t
+++ b/
t/10-request.t
@@
-4,7
+4,7
@@
use warnings;
my $debug = shift @ARGV;
my $debug = shift @ARGV;
-use Test::More tests =>
5
3;
+use Test::More tests =>
7
3;
use Data::Dump qw/dump/;
use Cwd qw/abs_path/;
use File::Slurp;
use Data::Dump qw/dump/;
use Cwd qw/abs_path/;
use File::Slurp;
@@
-21,6
+21,9
@@
ok( $#models + 1, 'got models' );
ok(my $abs_path = abs_path($0), "abs_path");
$abs_path =~ s!/[^/]*$!/!; #!fix-vim
ok(my $abs_path = abs_path($0), "abs_path");
$abs_path =~ s!/[^/]*$!/!; #!fix-vim
+my $path2method;
+my $triggers_count;
+
sub file_is_deeply {
my ( $path ) = @_;
sub file_is_deeply {
my ( $path ) = @_;
@@
-28,6
+31,14
@@
sub file_is_deeply {
diag $xml if $debug;
diag $xml if $debug;
+ ok( my $trigger = $path2method->{$path}, "path2method($path)" );
+
+ CWMP::Request->add_trigger( name => $trigger, callback => sub {
+ my ( $self, $state ) = @_;
+ $triggers_count->{$trigger}++;
+ ok( $state, "called trigger $trigger" );
+ });
+
ok( my $state = CWMP::Request->parse( $xml ), 'parse' );
my $dump_path = $path;
ok( my $state = CWMP::Request->parse( $xml ), 'parse' );
my $dump_path = $path;
@@
-47,7
+58,13
@@
foreach my $model ( @models ) {
my $dir = "$abs_path/$model/";
opendir(DIR, $dir) || die "can't opendir $dir: $!";
my $dir = "$abs_path/$model/";
opendir(DIR, $dir) || die "can't opendir $dir: $!";
- my @xmls = map { "$dir/$_" } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);
+ my @xmls = map {
+ my $path = "$dir/$_";
+ my $method = $_;
+ $method =~ s/\.xml$//;
+ $path2method->{$path} = $method;
+ $path;
+ } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);
closedir DIR;
diag "$model has ", $#xmls + 1, " xml tests";
closedir DIR;
diag "$model has ", $#xmls + 1, " xml tests";
@@
-60,3
+77,5
@@
foreach my $model ( @models ) {
}
}
}
}
+diag "triggers_count = ",dump( $triggers_count ) if $debug;
+