projects
/
perl-cwmp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remote cwmp namespace from SetParameterValues
[perl-cwmp.git]
/
t
/
10-request.t
diff --git
a/t/10-request.t
b/t/10-request.t
index
80243a7
..
33d4f56
100755
(executable)
--- a/
t/10-request.t
+++ b/
t/10-request.t
@@
-4,12
+4,15
@@
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 blib;
use Data::Dump qw/dump/;
use Cwd qw/abs_path/;
use File::Slurp;
use blib;
+# XML::Rules doesn't like it!
+#use Devel::LeakTrace::Fast;
+
BEGIN {
use_ok('CWMP::Request');
}
BEGIN {
use_ok('CWMP::Request');
}
@@
-21,6
+24,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
+34,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
+61,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
+80,5
@@
foreach my $model ( @models ) {
}
}
}
}
+diag "triggers_count = ",dump( $triggers_count ) if $debug;
+