/[cwmp]/google/branches/store-pluggable/t/05-store.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /google/branches/store-pluggable/t/05-store.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 138 - (show annotations)
Fri Oct 26 21:25:08 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1504 byte(s)
everything uses yaml for now
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = shift @ARGV;
6
7 use Test::More tests => 18;
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 use_ok('CWMP::Store::DBMDeep');
15 }
16
17 ok(my $abs_path = abs_path($0), "abs_path");
18 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
19
20 my $path = "$abs_path/var/state.db";
21
22 unlink $path if -e $path;
23
24 ok( my $store = CWMP::Store->new({
25 debug => $debug,
26 # module => 'DBMDeep',
27 module => 'YAML',
28 path => $path,
29 }), 'new' );
30 isa_ok( $store, 'CWMP::Store' );
31
32 cmp_ok( $store->path, 'eq', $path, 'path' );
33
34 my $state = {
35 foo => 'bar',
36 DeviceID => {
37 SerialNumber => 123456,
38 },
39 };
40
41 cmp_ok( $store->ID_to_uid( 42, $state ), 'eq', 123456, 'ID_to_uid' );
42
43 ok( $store->update_state( ID => 42, $state ), 'update_state new' );
44
45 ok( my $store_state = $store->state( ID => '42'), 'db->get' );
46
47 is_deeply( $store_state, $state, 'state ID' );
48
49 ok( $store_state = $store->state( uid => 123456 ), 'db->get' );
50
51 is_deeply( $store_state, $state, 'state uid' );
52
53 ok( $store->update_state( ID => 42, { baz => 12345 } ), 'update_state existing' );
54
55 $state->{baz} = 12345;
56
57 is_deeply( $store->state( ID => 42 ), $state, 'store->state ID' );
58
59 is_deeply( $store->state( uid => 123456 ), $state, 'store->state uid' );
60
61 is_deeply( [ $store->known_CPE ], [ 123456 ], 'known_CPE' );
62
63 ok( $store->update_state( ID => 11, { DeviceID => { SerialNumber => 99999 } } ), 'new device' );
64
65 is_deeply( [ $store->known_CPE ], [ 123456, 99999 ], 'known_CPE' );
66

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26