summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-03-04 10:53:36 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-03-04 10:56:16 +0100
commitd19c50977b10e379418e879acb7b6b5463081729 (patch)
treee1178d4496369373c2306be057e63d27fb4be9ef
parent404e41dccfa21114cc35c16e3d952f1e7c19136c (diff)
downloadApp-BorgRestore-d19c50977b10e379418e879acb7b6b5463081729.tar.gz
App-BorgRestore-d19c50977b10e379418e879acb7b6b5463081729.tar.xz
Test timespec_to_seconds
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--t/03_timespec.t21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/03_timespec.t b/t/03_timespec.t
new file mode 100644
index 0000000..a131512
--- /dev/null
+++ b/t/03_timespec.t
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use App::BorgRestore;
+
+my $app = App::BorgRestore->new({}, {borg => 0, db => 0});
+
+is($app->timespec_to_seconds('5s'), 5, '5 seconds');
+is($app->timespec_to_seconds('5minutes'), 5*60, '5 minutes');
+is($app->timespec_to_seconds('6d'), 6*60*60*24, '6 days');
+is($app->timespec_to_seconds('8m'), 8*60*60*24*31, '8 months');
+is($app->timespec_to_seconds('2y'), 2*60*60*24*365, '2 years');
+
+is($app->timespec_to_seconds('5sec'), undef, 'invalid unit returns undef');
+is($app->timespec_to_seconds('5'), undef, 'missing unit returns undef');
+is($app->timespec_to_seconds('blub'), undef, 'string returns undef');
+is($app->timespec_to_seconds(''), undef, 'empty string returns undef');
+
+done_testing;