5 my $debug = shift @ARGV;
7 use Test::More tests => 32;
8 use Data::Dump qw/dump/;
12 #use Devel::LeakTrace::Fast;
15 use_ok('CWMP::Store');
16 use_ok('CWMP::Store::YAML');
17 use_ok('CWMP::Store::JSON');
20 ok(my $abs_path = abs_path($0), "abs_path");
21 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
23 my $path = "$abs_path/var/";
28 diag "testing store plugin $module";
30 ok( my $store = CWMP::Store->new({
36 isa_ok( $store, 'CWMP::Store' );
38 cmp_ok( $store->path, 'eq', $path, 'path' );
43 SerialNumber => 123456,
47 cmp_ok( $store->state_to_uid( $state ), 'eq', 123456, 'state_to_uid' );
49 ok( $store->update_state( $state ), 'update_state new' );
51 ok( my $store_state = $store->get_state( 123456 ), 'get_state' );
53 isa_ok( $state, 'HASH' );
54 isa_ok( $store_state, 'HASH' );
58 diag "store_state = ",dump( $store_state );
62 is_deeply( $state, $store_state, 'state ID same as uid' );
66 SerialNumber => 123456,
71 ok( $store->set_state( 123456, $state ), 'set_state' );
73 is_deeply( $store->get_state( 123456 ), $state, 'get_state' );
75 is_deeply( [ $store->all_uids ], [ 123456 ], 'all_uids' );
77 ok( $store->update_state( { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
79 is_deeply( [ $store->all_uids ], [ 123456, 99999 ], 'all_uids' );