/[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 79 by dpavlin, Fri Jun 22 14:32:13 2007 UTC google/trunk/t/05-store.t revision 156 by dpavlin, Sat Oct 27 22:54:28 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 => 8;  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");
18  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim
19    
20  my $path = "$abs_path/var/state.db";  my $path = "$abs_path/var/";
21    
22    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            module => 'YAML',
28          path => $path,          path => $path,
29  }), 'new' );  }), 'new' );
30  isa_ok( $store, 'CWMP::Store' );  isa_ok( $store, 'CWMP::Store' );
31    
32  cmp_ok( $store->path, 'eq', $path, 'path' );  cmp_ok( $store->path, 'eq', $path, 'path' );
33    
34  ok( $store->update_state( 42, { foo => 'bar' } ), 'update_state' );  my $state = {
35            foo => 'bar',
36            DeviceID => {
37                    SerialNumber => 123456,
38            },
39    };
40    
41    cmp_ok( $store->ID_to_uid( 42, $state ), 'eq', 123456, 'ID_to_uid' );
42    
43    ok( $store->update_state( ID => 42, $state ), 'update_state new' );
44    
45    ok( my $store_state = $store->state( ID => '42'), 'db->get' );
46    
47    is_deeply( $store_state, $state, 'state ID' );
48    
49    ok( $store_state = $store->state( uid =>  123456 ), 'db->get' );
50    
51    is_deeply( $store_state, $state, 'state uid' );
52    
53    ok( $store->update_state( ID => 42, { baz => 12345 } ), 'update_state existing' );
54    
55    $state->{baz} = 12345;
56    
57    is_deeply( $store->state( ID => 42 ), $state, 'store->state ID' );
58    
59    is_deeply( $store->state( uid => 123456 ), $state, 'store->state uid' );
60    
61    is_deeply( [ $store->known_CPE ], [ 123456 ], 'known_CPE' );
62    
63    ok( $store->update_state( ID => 11, { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
64    
65  ok( my $state = $store->db->get('42'), 'db->get' );  is_deeply( [ $store->known_CPE ], [ 123456, 99999 ], 'known_CPE' );
66    
 is_deeply( $state, { foo => 'bar' }, 'state' );  

Legend:
Removed from v.79  
changed lines
  Added in v.156

  ViewVC Help
Powered by ViewVC 1.1.26