/[cwmp]/google/trunk/t/06-queue.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

Contents of /google/trunk/t/06-queue.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 227 - (show annotations)
Sun Nov 25 18:51:26 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 914 byte(s)
 r266@brr:  dpavlin | 2007-11-25 19:50:35 +0100
 - first pass with Devel::LeakTrace::Fast
 - remove DBM::Deep store
 - CWMP::Queue now supports dir and clean args
 - create new parser for each request

1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = shift @ARGV;
6
7 use Test::More tests => 256;
8 use Data::Dump qw/dump/;
9 use lib 'lib';
10
11 use Devel::LeakTrace::Fast;
12
13 BEGIN {
14 use_ok('CWMP::Queue');
15 }
16
17 use Cwd qw/abs_path/;
18 ok(my $abs_path = abs_path($0), "abs_path");
19 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
20
21 ok( my $obj = CWMP::Queue->new({
22 id => 'test',
23 dir => "$abs_path/queue",
24 clean => 1,
25 debug => $debug,
26 }), 'new' );
27 isa_ok( $obj, 'CWMP::Queue' );
28
29 for my $i ( 1 .. 42 ) {
30 ok( $obj->enqueue(
31 "command-$i",
32 {
33 i => $i,
34 foo => 'bar',
35 }
36 ), "enqueue $i" );
37 };
38
39 my $i = 1;
40
41 while ( my $job = $obj->dequeue ) {
42 ok( $job, "dequeue $i" );
43 ok( my ( $dispatch, $args ) = $job->dispatch, "job->dispatch $i" );
44 cmp_ok( $dispatch, 'eq', "command-$i", "dispatch $i" );
45 diag "args = ",dump( $args ) if $debug;
46 cmp_ok( $args->{i}, '==', $i, "args i == $i" );
47 ok( $job->finish, "finish $i" );
48 $i++;
49 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26