X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-File-KDBX;a=blobdiff_plain;f=t%2Fdatabase.t;h=8bed335b351ef60e87d4f2d71ae6ff15b7b8de5a;hp=d4edfb2662dc81e5624b72d6f44102075f0c3714;hb=796fdad82448b51f9c990ca461df647341a84b7e;hpb=84a35b3fe4421abbe930586dd3a214cbb15da9b7 diff --git a/t/database.t b/t/database.t index d4edfb2..8bed335 100644 --- a/t/database.t +++ b/t/database.t @@ -9,6 +9,7 @@ use lib "$Bin/lib"; use TestCommon; use File::KDBX; +use File::Temp qw(tempfile); use Test::Deep; use Test::More; use Time::Piece; @@ -170,4 +171,24 @@ subtest 'Maintenance' => sub { is $entry->custom_icon_uuid, $icon_uuid, 'Uses of removed icon change'; }; +subtest 'Dumping to filesystem' => sub { + my $kdbx = File::KDBX->new; + $kdbx->add_entry(title => 'Foo', password => 'whatever'); + + my ($fh, $filepath) = tempfile('kdbx-XXXXXX', TMPDIR => 1, UNLINK => 1); + close($fh); + + $kdbx->dump($filepath, 'a'); + + my $kdbx2 = File::KDBX->load($filepath, 'a'); + my $entry = $kdbx2->entries->map(sub { $_->title.'/'.$_->expand_password })->next; + is $entry, 'Foo/whatever', 'Dump and load an entry'; + + $kdbx->dump($filepath, key => 'a', atomic => 0); + + $kdbx2 = File::KDBX->load($filepath, 'a'); + $entry = $kdbx2->entries->map(sub { $_->title.'/'.$_->expand_password })->next; + is $entry, 'Foo/whatever', 'Dump and load an entry (non-atomic)'; +}; + done_testing;