4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
6 |
|
|
7 |
use Test::More tests => 8; |
use Test::More tests => 10; |
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'; |
18 |
|
|
19 |
my $path = "$abs_path/var/state.db"; |
my $path = "$abs_path/var/state.db"; |
20 |
|
|
21 |
|
unlink $path if -e $path; |
22 |
|
|
23 |
ok( my $store = CWMP::Store->new({ |
ok( my $store = CWMP::Store->new({ |
24 |
debug => $debug, |
debug => $debug, |
25 |
path => $path, |
path => $path, |
28 |
|
|
29 |
cmp_ok( $store->path, 'eq', $path, 'path' ); |
cmp_ok( $store->path, 'eq', $path, 'path' ); |
30 |
|
|
31 |
ok( $store->update_state( 42, { foo => 'bar' } ), 'update_state' ); |
ok( $store->update_state( 42, { foo => 'bar' } ), 'update_state new' ); |
32 |
|
|
33 |
ok( my $state = $store->db->get('42'), 'db->get' ); |
ok( my $state = $store->db->get('42'), 'db->get' ); |
34 |
|
|
35 |
is_deeply( $state, { foo => 'bar' }, 'state' ); |
is_deeply( $state, { foo => 'bar' }, 'state' ); |
36 |
|
|
37 |
|
ok( $store->update_state( 42, { baz => 12345 } ), 'update_state existing' ); |
38 |
|
|
39 |
|
is_deeply( $state, { foo => 'bar', baz => 12345 }, 'new state' ); |