commit ade98d66ea8004aa8eb85459095e3b41b2c8dfc3
parent 3c3e097a8175744053d33ef78e7b9147c198e93c
Author: Andreas Guldstrand <andreas.guldstrand@gmail.com>
Date: Thu, 5 May 2016 23:42:25 +0200
19-unit.t: test user_prompt() with undef location
Diffstat:
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/t/19-unit.t b/t/19-unit.t
@@ -8,11 +8,11 @@ use Test::More;
use Test::Exit;
use FindBin '$RealBin';
use lib "$RealBin/../SBO-Lib/lib";
-use SBO::Lib qw/ script_error usage_error open_fh %config indent get_installed_packages get_sbo_location get_sbo_locations get_local_outdated_versions get_readme_contents /;
+use SBO::Lib qw/ script_error usage_error open_fh %config indent get_installed_packages get_sbo_location get_sbo_locations get_local_outdated_versions get_readme_contents user_prompt /;
use Capture::Tiny qw/ capture_merged /;
use File::Temp 'tempdir';
-plan tests => 42;
+plan tests => 44;
# 1-2: test script_error();
{
@@ -252,3 +252,12 @@ SKIP: {
is ($ret[0], undef, "get_readme_contents() returned undef");
is ($ret[1], 6, "get_readme_contents() returned 6");
}
+
+# 43-44: test user_prompt();
+{
+ my $exit;
+ my $out = capture_merged { $exit = exit_code { user_prompt('foo', undef); }; };
+
+ is ($exit, 1, 'user_prompt() exited with 1');
+ is ($out, "Unable to locate foo in the SlackBuilds.org tree.\n", 'user_prompt() gave correct output');
+}