aboutsummaryrefslogtreecommitdiff
path: root/t/18-snap.t
blob: 2e028a13d5a889bb437c94737274506eb19b4086 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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 Test::Sbotools qw/ sbosnap set_gpg_verify set_repo set_sbo_home /;
use File::Temp 'tempdir';

plan tests => 4;

my $usage = <<'SBOSNAP';
Usage: sbosnap [options|command]

Options:
  -h|--help:
    this screen.
  -v|--version:
    version information.

Commands:
  fetch: initialize a local copy of the slackbuilds.org tree.
  import-key [path or url]: import GPG for verifying the slackbuilds.org tree. Defaults to the key shipped with sbotools2.
  update: update an existing local copy of the slackbuilds.org tree.
          (generally, you may prefer "sbocheck" over "sbosnap update")

SBOSNAP

# 1: sbosnap errors without arguments
sbosnap { exit => 1, expected => $usage };

# 2: sbosnap invalid errors
sbosnap 'invalid', { exit => 1, expected => $usage };

# 3: sbosnap update when /usr/sbo/repo is empty
my $tmp = tempdir(CLEANUP => 1);
set_gpg_verify('FALSE');
set_repo("file://$tmp");
capture_merged { system <<"END"; };
cd $tmp
git init
mkdir test
cp -a $RealBin/LO/nonexistentslackbuild test
git add test
git commit -m 'test'
END

sbosnap 'update', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ };

# 4-5: sbosnap when SBO_HOME is set
my $tmphome = tempdir(CLEANUP => 1);
set_sbo_home($tmphome);

sbosnap 'fetch', { test => 0, note => 1 };
note scalar `ls -R $tmphome`;
ok (-e "$tmphome/repo/test/nonexistentslackbuild/nonexistentslackbuild.info", 'SBo tree pulled to correct location');