5 my $debug = shift @ARGV;
7 use Test::More tests => 47;
8 use Data::Dump qw/dump/;
12 #use Devel::LeakTrace::Fast;
15 use_ok('CWMP::Store');
16 use_ok('CWMP::Store::DBMDeep');
17 use_ok('CWMP::Store::YAML');
18 use_ok('CWMP::Store::JSON');
21 ok(my $abs_path = abs_path($0), "abs_path");
22 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
24 my $path = "$abs_path/var/";
29 diag "testing store plugin $module";
31 ok( my $store = CWMP::Store->new({
37 isa_ok( $store, 'CWMP::Store' );
39 cmp_ok( $store->path, 'eq', $path, 'path' );
44 SerialNumber => 123456,
48 cmp_ok( $store->state_to_uid( $state ), 'eq', 123456, 'state_to_uid' );
50 ok( $store->update_state( $state ), 'update_state new' );
52 ok( my $store_state = $store->get_state( 123456 ), 'get_state' );
54 isa_ok( $state, 'HASH' );
55 isa_ok( $store_state, 'HASH' );
59 diag "store_state = ",dump( $store_state );
63 is_deeply( $state, $store_state, 'state ID same as uid' );
65 ok( $store->update_state( {
67 SerialNumber => 123456,
70 } ), 'update_state existing' );
72 $state->{baz} = 12345;
74 is_deeply( $store->get_state( 123456 ), $state, 'get_state' );
76 is_deeply( [ $store->all_uids ], [ 123456 ], 'all_uids' );
78 ok( $store->update_state( { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
80 is_deeply( [ $store->all_uids ], [ 123456, 99999 ], 'all_uids' );
88 test_store('DBMDeep');