1 |
#!/usr/bin/perl |
2 |
use strict; |
3 |
use warnings; |
4 |
|
5 |
my $debug = shift @ARGV; |
6 |
|
7 |
use Test::More tests => 8; |
8 |
use Data::Dump qw/dump/; |
9 |
use Cwd qw/abs_path/; |
10 |
use lib 'lib'; |
11 |
|
12 |
BEGIN { |
13 |
use_ok('CWMP::Store'); |
14 |
} |
15 |
|
16 |
ok(my $abs_path = abs_path($0), "abs_path"); |
17 |
$abs_path =~ s!/[^/]*$!/!; #!fix-vim |
18 |
|
19 |
my $path = "$abs_path/var/state.db"; |
20 |
|
21 |
ok( my $store = CWMP::Store->new({ |
22 |
debug => $debug, |
23 |
path => $path, |
24 |
}), 'new' ); |
25 |
isa_ok( $store, 'CWMP::Store' ); |
26 |
|
27 |
cmp_ok( $store->path, 'eq', $path, 'path' ); |
28 |
|
29 |
ok( $store->update_state( 42, { foo => 'bar' } ), 'update_state' ); |
30 |
|
31 |
ok( my $state = $store->db->get('42'), 'db->get' ); |
32 |
|
33 |
is_deeply( $state, { foo => 'bar' }, 'state' ); |