aboutsummaryrefslogtreecommitdiff
path: root/t/06-remove.t
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-01-02 20:48:32 +0100
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-01-02 20:48:32 +0100
commita605927dc5ae1e3a697cef2829be4e63af526645 (patch)
tree98e39e8f569a2ed784a794884e2caaab265006e0 /t/06-remove.t
parent17359488f2701f19d06529e98e93a18f52c3bf10 (diff)
downloadsbotools-a605927dc5ae1e3a697cef2829be4e63af526645.tar.xz
Rename test files so they get run in a nicer order
Diffstat (limited to 't/06-remove.t')
-rwxr-xr-xt/06-remove.t90
1 files changed, 90 insertions, 0 deletions
diff --git a/t/06-remove.t b/t/06-remove.t
new file mode 100755
index 0000000..dfe4c6f
--- /dev/null
+++ b/t/06-remove.t
@@ -0,0 +1,90 @@
+#!/usr/bin/env perl
+
+use 5.16.0;
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+use Capture::Tiny qw/ capture_merged /;
+use FindBin '$RealBin';
+use lib $RealBin;
+use lib "$RealBin/../SBO-Lib/lib";
+use Test::Execute;
+
+if ($ENV{TEST_INSTALL}) {
+ plan tests => 4;
+} else {
+ plan skip_all => 'Only run these tests if TEST_INSTALL=1';
+}
+$ENV{TEST_ONLINE} //= 0;
+
+$path = "$RealBin/../";
+
+sub cleanup {
+ capture_merged {
+ system(qw!/sbin/removepkg nonexistentslackbuild!);
+ system(qw!/sbin/removepkg nonexistentslackbuild4!);
+ system(qw!/sbin/removepkg nonexistentslackbuild5!);
+ unlink "$RealBin/LO/nonexistentslackbuild/perf.dummy";
+ unlink "$RealBin/LO/nonexistentslackbuild4/perf.dummy";
+ unlink "$RealBin/LO/nonexistentslackbuild5/perf.dummy";
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.0!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-1.0!);
+ system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.0!);
+ system(qw!rm -rf /tmp/package-nonexistentslackbuild!);
+ system(qw!rm -rf /tmp/package-nonexistentslackbuild4!);
+ system(qw!rm -rf /tmp/package-nonexistentslackbuild5!);
+ };
+}
+
+sub make_slackbuilds_txt {
+ state $made = 0;
+ my $fname = "/usr/sbo/repo/SLACKBUILDS.TXT";
+ if ($_[0]) {
+ if ($made) { return system(qw!rm -rf!, $fname); }
+ } else {
+ if (not -e $fname) { $made = 1; system('mkdir', '-p', '/usr/sbo/repo'); system('touch', $fname); }
+ }
+}
+
+sub set_lo {
+ state $set = 0;
+ state $lo;
+ if ($_[0]) {
+ if ($set) { script (qw/ sboconfig -o /, $lo, { test => 0 }); }
+ } else {
+ ($lo) = script (qw/ sboconfig -l /, { expected => qr/LOCAL_OVERRIDES=(.*)/, test => 0 });
+ $lo //= 'FALSE';
+ note "Saving original value of LOCAL_OVERRIDES: $lo";
+ $set = 1;
+ script (qw/ sboconfig -o /, "$RealBin/LO", { test => 0 });
+ }
+}
+
+cleanup();
+make_slackbuilds_txt();
+set_lo();
+
+
+# 1: sboremove nonexistentslackbuild
+script (qw/ sboinstall nonexistentslackbuild /, { input => "y\ny", test => 0 });
+script (qw/ sboremove nonexistentslackbuild /, { input => "y\ny", expected => qr/Remove nonexistentslackbuild\b.*Removing 1 package\(s\)/s });
+
+# 2: sboremove nonexistentslackbuild5
+script (qw/ sboinstall nonexistentslackbuild4 /, { input => "y\ny\ny", test => 0 });
+script (qw/ sboremove nonexistentslackbuild5 /, { input => "y\ny", expected => qr/Remove nonexistentslackbuild5\b.*Removing 1 package\(s\)/s });
+
+# 3: sboremove nonexistentslackbuild4
+script (qw/ sboinstall nonexistentslackbuild5 /, { input => "y\ny", test => 0 });
+script (qw/ sboremove nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Remove nonexistentslackbuild4\b.*Remove nonexistentslackbuild5\b.*Removing 2 package\(s\)/s });
+
+# 4: sboremove nonexistentslackbuild4 nonexistentslackbuild5
+script (qw/ sboinstall nonexistentslackbuild4 /, { input => "y\ny\ny", test => 0 });
+script (qw/ sboremove nonexistentslackbuild4 nonexistentslackbuild5 /, { input => "y\ny\ny",
+ expected => qr/Remove nonexistentslackbuild4\b.*Remove nonexistentslackbuild5\b.*Removing 2 package\(s\)/s });
+
+# Cleanup
+END {
+ set_lo('delete');
+ make_slackbuilds_txt('delete');
+ cleanup();
+}