18-snap.t (1580B)
1 #!/usr/bin/env perl 2 3 use 5.16.0; 4 use strict; 5 use warnings FATAL => 'all'; 6 use Test::More; 7 use Capture::Tiny qw/ capture_merged /; 8 use FindBin '$RealBin'; 9 use lib $RealBin; 10 use Test::Sbotools qw/ sbosnap set_gpg_verify set_repo set_sbo_home /; 11 use File::Temp 'tempdir'; 12 13 plan tests => 4; 14 15 my $usage = <<'SBOSNAP'; 16 Usage: sbosnap [options|command] 17 18 Options: 19 -h|--help: 20 this screen. 21 -v|--version: 22 version information. 23 24 Commands: 25 fetch: initialize a local copy of the slackbuilds.org tree. 26 import-key [path or url]: import GPG for verifying the slackbuilds.org tree. Defaults to the key shipped with sbotools2. 27 update: update an existing local copy of the slackbuilds.org tree. 28 (generally, you may prefer "sbocheck" over "sbosnap update") 29 30 SBOSNAP 31 32 # 1: sbosnap errors without arguments 33 sbosnap { exit => 1, expected => $usage }; 34 35 # 2: sbosnap invalid errors 36 sbosnap 'invalid', { exit => 1, expected => $usage }; 37 38 # 3: sbosnap update when /usr/sbo/repo is empty 39 my $tmp = tempdir(CLEANUP => 1); 40 set_gpg_verify('FALSE'); 41 set_repo("file://$tmp"); 42 capture_merged { system <<"END"; }; 43 cd $tmp 44 git init 45 mkdir test 46 cp -a $RealBin/LO/nonexistentslackbuild test 47 git add test 48 git commit -m 'test' 49 END 50 51 sbosnap 'update', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ }; 52 53 # 4-5: sbosnap when SBO_HOME is set 54 my $tmphome = tempdir(CLEANUP => 1); 55 set_sbo_home($tmphome); 56 57 sbosnap 'fetch', { test => 0, note => 1 }; 58 note scalar `ls -R $tmphome`; 59 ok (-e "$tmphome/repo/test/nonexistentslackbuild/nonexistentslackbuild.info", 'SBo tree pulled to correct location');