5 my $debug = shift @ARGV;
7 use Test::More tests => 34;
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->ID_to_uid( 42, $state ), 'eq', 123456, 'ID_to_uid' );
47 ok( $store->update_state( ID => 42, $state ), 'update_state new' );
49 ok( my $store_state = $store->get_state( ID => '42'), 'get_state ID' );
51 is_deeply( $store_state, $state, 'state ID' );
53 ok( $store_state = $store->get_state( uid => 123456 ), 'get_state uid' );
55 is_deeply( $store_state, $state, 'state ID same as uid' );
57 ok( $store->update_state( ID => 42, { baz => 12345 } ), 'update_state existing' );
59 $state->{baz} = 12345;
61 is_deeply( $store->get_state( ID => 42 ), $state, 'get_state ID' );
63 is_deeply( $store->get_state( uid => 123456 ), $state, 'get_state uid' );
65 is_deeply( [ $store->all_uids ], [ 123456 ], 'all_uids' );
67 ok( $store->update_state( ID => 11, { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
69 is_deeply( [ $store->all_uids ], [ 123456, 99999 ], 'all_uids' );
75 test_store('DBMDeep');