]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/kdbx4.t
Prereq Test::More 1.001004_001 to fix broken tests
[chaz/p5-File-KDBX] / t / kdbx4.t
index 663a1b8b31aa326a426ee65610725f50db13828f..ff487003614358615a58ea0eaecdc436d623af6c 100644 (file)
--- a/t/kdbx4.t
+++ b/t/kdbx4.t
@@ -10,7 +10,7 @@ use TestCommon;
 use File::KDBX;
 use File::KDBX::Constants qw(:version :kdf);
 use Test::Deep;
-use Test::More;
+use Test::More 1.001004_001;
 use boolean qw(:all);
 
 subtest 'Verify Format400' => sub {
@@ -25,11 +25,11 @@ subtest 'Verify Format400' => sub {
         encryption_iv => "3?\207P\233or\220\215h\2240",
         kdf_parameters => {
             "\$UUID" => "\357cm\337\214)DK\221\367\251\244\3\343\n\f",
-            I => 2,
-            M => 1048576,
-            P => 2,
+            I => num(2),
+            M => num(1048576),
+            P => num(2),
             S => "V\254\6m-\206*\260\305\f\0\366\24:4\235\364A\362\346\221\13)}\250\217P\303\303\2\331\245",
-            V => 19,
+            V => num(19),
         },
         master_seed => ";\372y\300yS%\3331\177\231\364u\265Y\361\225\3273h\332R,\22\240a\240\302\271\357\313\23",
     }, 'Extract headers' or diag explain $kdbx->headers;
@@ -37,8 +37,8 @@ subtest 'Verify Format400' => sub {
     is $kdbx->meta->{database_name}, 'Format400', 'Extract database name from meta';
     is $kdbx->root->name, 'Format400', 'Extract name of root group';
 
-    my ($entry, @other) = $kdbx->find_entries([\'400', 'title']);
-    is @other, 0, 'Database has one entry';
+    my ($entry, @other) = $kdbx->entries->grep(\'400', 'title')->each;
+    is scalar @other, 0, 'Database has one entry';
 
     is $entry->title, 'Format400', 'Entry is titled';
     is $entry->username, 'Format400', 'Entry has a username set';
@@ -81,9 +81,9 @@ subtest 'KDBX4 upgrade' => sub {
 subtest 'KDBX4.1 upgrade' => sub {
     my $kdbx = File::KDBX->new;
 
-    my $group1 = $kdbx->add_group;
-    my $group2 = $kdbx->add_group;
-    my $entry1 = $kdbx->add_entry;
+    my $group1 = $kdbx->add_group(label => 'One');
+    my $group2 = $kdbx->add_group(label => 'Two');
+    my $entry1 = $kdbx->add_entry(label => 'Meh');
 
     $group1->tags('hi');
     is $kdbx->minimum_version, KDBX_VERSION_4_1, 'Groups with tags requires upgrade';
@@ -109,11 +109,11 @@ subtest 'KDBX4.1 upgrade' => sub {
     is $kdbx->minimum_version, KDBX_VERSION_3_1, 'Icon with no metadata requires no upgrade';
     my $icon_uuid = $kdbx->add_custom_icon('data2', name => 'icon name');
     is $kdbx->minimum_version, KDBX_VERSION_4_1, 'Icon with name requires upgrade';
-    delete $kdbx->custom_icons->{$icon_uuid};
+    $kdbx->remove_custom_icon($icon_uuid);
     is $kdbx->minimum_version, KDBX_VERSION_3_1, 'Reset upgrade requirement';
-    $icon_uuid = $kdbx->add_custom_icon('data2', last_modification_time => gmtime);
+    $icon_uuid = $kdbx->add_custom_icon('data2', last_modification_time => scalar gmtime);
     is $kdbx->minimum_version, KDBX_VERSION_4_1, 'Icon with modtime requires upgrade';
-    delete $kdbx->custom_icons->{$icon_uuid};
+    $kdbx->remove_custom_icon($icon_uuid);
     is $kdbx->minimum_version, KDBX_VERSION_3_1, 'Reset upgrade requirement';
 
     $entry1->custom_data(foo => 'bar', last_modification_time => scalar gmtime);
@@ -205,12 +205,12 @@ subtest 'Custom data' => sub {
     ok isBoolean($kdbx2->public_custom_data->{bool}), 'Boolean is indeed a boolean';
     is $kdbx2->public_custom_data->{bytes}, "\1\2\3\4", 'Store some bytes in public custom data';
 
-    my ($group2) = $kdbx2->find_groups({label => 'Group'});
+    my $group2 = $kdbx2->groups->grep(label => 'Group')->next;
     is_deeply $group2->custom_data_value('str'), '你好', 'Store a string in group custom data';
     is_deeply $group2->custom_data_value('num'), '42', 'Store a number in group custom data';
     is_deeply $group2->custom_data_value('bool'), '1', 'Store a boolean in group custom data';
 
-    my ($entry2) = $kdbx2->find_entries({label => 'Entry'});
+    my $entry2 = $kdbx2->entries->grep(label => 'Entry')->next;
     is_deeply $entry2->custom_data_value('str'), '你好', 'Store a string in entry custom data';
     is_deeply $entry2->custom_data_value('num'), '42', 'Store a number in entry custom data';
     is_deeply $entry2->custom_data_value('bool'), '0', 'Store a boolean in entry custom data';
This page took 0.026773 seconds and 4 git commands to generate.