From 13f51c2044fb22f6b3cb8c674a23fe636f7fb33d Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 19 Aug 2018 14:48:47 +0200 Subject: Reorganize tests Signed-off-by: Florian Pritz --- t/timespec_to_seconds.t | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 t/timespec_to_seconds.t (limited to 't/timespec_to_seconds.t') diff --git a/t/timespec_to_seconds.t b/t/timespec_to_seconds.t new file mode 100644 index 0000000..0f367c9 --- /dev/null +++ b/t/timespec_to_seconds.t @@ -0,0 +1,21 @@ +use strict; +use warnings; + +use Test::More; + +use App::BorgRestore; + +my $app = App::BorgRestore->new_no_defaults(undef); + +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; -- cgit v1.2.3-24-g4f1b