summaryrefslogtreecommitdiff
path: root/t/24_annex-review-unused.t
blob: 4947455fe3d5ab5940dde4875ff0ba20d7e97ae3 (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
#!/usr/bin/perl

use 5.028;
use strict;
use warnings;
use lib 't/lib';

use App::annex_review_unused;
use Test::More;
use t::Setup;
use t::Util;
use File::chdir;
use File::Spec::Functions qw(rel2abs);
use Capture::Tiny qw(capture_stdout);

plan skip_all => "git-annex not available" unless git_annex_available;

with_temp_annexes {
    my (undef, $source1) = @_;
    my ($output, $exit);

    {
        local $CWD = "source1";
        (undef, undef, $exit) = run_bin "annex-review-unused";
        ok !$exit, "it exits zero when no unused files";
        sleep 1;
        $source1->rm("foo/foo2/baz");
        $source1->commit({ message => "rm" });

        ($output, undef, $exit) = run_bin qw(annex-review-unused --just-print);
        ok $exit, "it exits nonzero when unused files";
        ok 20 < @$output && @$output < 30, "it prints ~two log entries";
        like $output->[5], qr/unused file #1/, "it prints an expected line";
    }
};

done_testing;