Added unflocks to all tests so that the tests run on OSX
[dbsrgits/DBM-Deep.git] / t / 19_crossref.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 5;
98ac82af 6use File::Temp qw( tempfile tempdir );
58910373 7use Fcntl qw( :flock );
ffed8b01 8
9use_ok( 'DBM::Deep' );
10
98ac82af 11my $dir = tempdir( CLEANUP => 1 );
12my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
58910373 13flock $fh2, LOCK_UN;
98ac82af 14my $db2 = DBM::Deep->new( $filename2 );
15
16{
17 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
58910373 18 flock $fh, LOCK_UN;
98ac82af 19 my $db = DBM::Deep->new( $filename );
20
21 ##
22 # Create structure in $db
23 ##
24 $db->import(
25 hash1 => {
26 subkey1 => "subvalue1",
c9cec40e 27 subkey2 => "subvalue2",
98ac82af 28 }
29 );
98ac82af 30 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
31 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
32
33 ##
34 # Cross-ref nested hash accross DB objects
35 ##
36 $db2->{copy} = $db->{hash1};
37}
ffed8b01 38
39##
40# Make sure $db2 has copy of $db's hash structure
41##
42is( $db2->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
43is( $db2->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );