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

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

google/t/05-store.t revision 95 by dpavlin, Sat Jun 23 09:23:08 2007 UTC google/trunk/t/05-store.t revision 150 by dpavlin, Sat Oct 27 22:53:14 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4    
5  my $debug = shift @ARGV;  my $debug = shift @ARGV;
6    
7  use Test::More tests => 14;  use Test::More tests => 18;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
10  use lib 'lib';  use lib 'lib';
11    
12  BEGIN {  BEGIN {
13          use_ok('CWMP::Store');          use_ok('CWMP::Store');
14            use_ok('CWMP::Store::DBMDeep');
15  }  }
16    
17  ok(my $abs_path = abs_path($0), "abs_path");  ok(my $abs_path = abs_path($0), "abs_path");
# Line 22  unlink $path if -e $path; Line 23  unlink $path if -e $path;
23    
24  ok( my $store = CWMP::Store->new({  ok( my $store = CWMP::Store->new({
25          debug => $debug,          debug => $debug,
26            module => 'DBMDeep',
27          path => $path,          path => $path,
28  }), 'new' );  }), 'new' );
29  isa_ok( $store, 'CWMP::Store' );  isa_ok( $store, 'CWMP::Store' );
# Line 37  my $state = { Line 39  my $state = {
39    
40  cmp_ok( $store->ID_to_uid( 42, $state ), 'eq', 123456, 'ID_to_uid' );  cmp_ok( $store->ID_to_uid( 42, $state ), 'eq', 123456, 'ID_to_uid' );
41    
42  ok( $store->update_state( 42, $state ), 'update_state new' );  ok( $store->update_state( ID => 42, $state ), 'update_state new' );
43    
44  ok( my $store_state = $store->state('42'), 'db->get' );  ok( my $store_state = $store->state( ID => '42'), 'db->get' );
45    
46  is_deeply( $store_state, $state, 'state' );  is_deeply( $store_state, $state, 'state ID' );
47    
48  ok( $store->update_state( 42, { baz => 12345 } ), 'update_state existing' );  ok( $store_state = $store->state( uid =>  123456 ), 'db->get' );
49    
50    is_deeply( $store_state, $state, 'state uid' );
51    
52    ok( $store->update_state( ID => 42, { baz => 12345 } ), 'update_state existing' );
53    
54  $state->{baz} = 12345;  $state->{baz} = 12345;
55    
56  is_deeply( $store->state(42), $state, 'store->state' );  is_deeply( $store->state( ID => 42 ), $state, 'store->state ID' );
57    
58    is_deeply( $store->state( uid => 123456 ), $state, 'store->state uid' );
59    
60  is_deeply( [ $store->known_CPE ], [ 123456 ], 'known_CPE' );  is_deeply( [ $store->known_CPE ], [ 123456 ], 'known_CPE' );
61    
62  ok( $store->update_state( 11, { DeviceID => { SerialNumber => 99999 } } ), 'new device' );  ok( $store->update_state( ID => 11, { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
63    
64  is_deeply( [ $store->known_CPE ], [ 123456, 99999 ], 'known_CPE' );  is_deeply( [ $store->known_CPE ], [ 123456, 99999 ], 'known_CPE' );
65    

Legend:
Removed from v.95  
changed lines
  Added in v.150

  ViewVC Help
Powered by ViewVC 1.1.26