use TestCommon;
use File::KDBX;
+use File::Temp qw(tempfile);
use Test::Deep;
use Test::More;
use Time::Piece;
is $kdbx->entries->size, 1, 'Database is not empty';
is $kdbx->entries(searching => 1)->size, 0, 'Database has no entries if searching';
- cmp_ok $bin->entries_deeply->size, '==', 1, 'Recycle bin has an entry';
+ cmp_ok $bin->all_entries->size, '==', 1, 'Recycle bin has an entry';
$entry->recycle_or_remove;
is $kdbx->entries->size, 0, 'Remove entry if it is already in the recycle bin';
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;