]>
Dogcows Code - chaz/p5-File-KDBX/blob - t/database.t
15 subtest
'Create a new database' => sub {
16 my $kdbx = File
::KDBX-
>new;
18 $kdbx->add_group(name
=> 'Meh');
19 ok
$kdbx->_has_implicit_root, 'Database starts off with implicit root';
21 my $entry = $kdbx->add_entry({
23 password
=> {value
=> 'This is a secret!!!!!', protect
=> 1},
26 ok
!$kdbx->_has_implicit_root, 'Adding an entry to the root group makes it explicit';
29 ok
$kdbx->_has_implicit_root, 'Removing group makes the root group implicit again';
32 subtest
'Clone' => sub {
33 my $kdbx = File
::KDBX-
>new;
34 $kdbx->add_group(name
=> 'Passwords')->add_entry(title
=> 'My Entry');
36 my $copy = $kdbx->clone;
37 cmp_deeply
$copy, $kdbx, 'Clone keeps the same structure and data' or dumper
$copy;
39 isnt
$kdbx, $copy, 'Clone is a different object';
40 isnt
$kdbx->root, $copy->root,
41 'Clone root group is a different object';
42 isnt
$kdbx->root->groups->[0], $copy->root->groups->[0],
43 'Clone group is a different object';
44 isnt
$kdbx->root->groups->[0]->entries->[0], $copy->root->groups->[0]->entries->[0],
45 'Clone entry is a different object';
47 my @objects = (@{$copy->all_groups}, @{$copy->all_entries});
48 subtest
'Cloned objects refer to the cloned database' => sub {
49 plan tests
=> scalar @_;
50 for my $object (@objects) {
51 my $object_kdbx = eval { $object->kdbx };
52 is $object_kdbx, $copy, 'Object: ' . $object->label;
This page took 0.03721 seconds and 4 git commands to generate.