5 my $debug = shift @ARGV;
7 use Test::More tests => 32;
8 use Data::Dump qw/dump/;
13 use_ok('CWMP::Store');
14 use_ok('CWMP::Store::DBMDeep');
15 use_ok('CWMP::Store::YAML');
18 ok(my $abs_path = abs_path($0), "abs_path");
19 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
21 my $path = "$abs_path/var/";
26 diag "testing store plugin $module";
28 ok( my $store = CWMP::Store->new({
34 isa_ok( $store, 'CWMP::Store' );
36 cmp_ok( $store->path, 'eq', $path, 'path' );
41 SerialNumber => 123456,
45 cmp_ok( $store->state_to_uid( $state ), 'eq', 123456, 'state_to_uid' );
47 ok( $store->update_state( $state ), 'update_state new' );
49 ok( my $store_state = $store->get_state( 123456 ), 'get_state' );
51 isa_ok( $state, 'HASH' );
52 isa_ok( $store_state, 'HASH' );
56 diag "store_state = ",dump( $store_state );
60 is_deeply( $state, $store_state, 'state ID same as uid' );
62 ok( $store->update_state( {
64 SerialNumber => 123456,
67 } ), 'update_state existing' );
69 $state->{baz} = 12345;
71 is_deeply( $store->get_state( 123456 ), $state, 'get_state' );
73 is_deeply( [ $store->all_uids ], [ 123456 ], 'all_uids' );
75 ok( $store->update_state( { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
77 is_deeply( [ $store->all_uids ], [ 123456, 99999 ], 'all_uids' );
83 test_store('DBMDeep');