Removed last holdouts of t/test?.db
[dbsrgits/DBM-Deep.git] / t / 18_export.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 2;
6 use File::Temp qw( tempfile tempdir );
7
8 use_ok( 'DBM::Deep' );
9
10 my $dir = tempdir( CLEANUP => 1 );
11
12 my $struct;
13 {
14     my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
15     my $db = DBM::Deep->new( $filename );
16
17     ##
18     # Create structure in DB
19     ##
20     $db->import(
21         key1 => "value1",
22         key2 => "value2",
23         array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ] ],
24         hash1 => {
25             subkey1 => "subvalue1",
26             subkey2 => "subvalue2",
27         }
28     );
29
30     ##
31     # Export entire thing
32     ##
33     $struct = $db->export();
34 }
35
36 ##
37 # Make sure everything is here, outside DB
38 ##
39 ok(
40         ($struct->{key1} eq "value1") && 
41         ($struct->{key2} eq "value2") && 
42         ($struct->{array1} && 
43                 ($struct->{array1}->[0] eq "elem0") &&
44                 ($struct->{array1}->[1] eq "elem1") && 
45                 ($struct->{array1}->[2] eq "elem2") &&
46                 ($struct->{array1}->[3]{foo} eq "bar") &&
47                 ($struct->{array1}->[4][0] eq "5")
48         ) && 
49         ($struct->{hash1} &&
50                 ($struct->{hash1}->{subkey1} eq "subvalue1") && 
51                 ($struct->{hash1}->{subkey2} eq "subvalue2")
52         )
53 );