File: alien_build_plugin_prefer_goodversion.t

package info (click to toggle)
libalien-build-perl 2.84-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,116 kB
  • sloc: perl: 10,350; ansic: 134; sh: 66; makefile: 2
file content (87 lines) | stat: -rw-r--r-- 1,761 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use 5.008004;
use lib 'corpus/lib';
use Test2::V0 -no_srand => 1;
use Test::Alien::Build;
use Alien::Build::Plugin::Prefer::GoodVersion;
use Path::Tiny qw( path );

eval { require Sort::Versions };
skip_all 'test requires Sort::Versions' if $@;

$Alien::Build::Plugin::Prefer::GoodVersion::VERSION ||= '1.44';

subtest 'compiles okay' => sub {

  alienfile_ok q{
    use alienfile;
    plugin 'Prefer::GoodVersion' => '1.2.3';
  };

};

subtest 'filter is required' => sub {

  eval {
    alienfile q{
      use alienfile;
      plugin 'Prefer::GoodVersion';
    }
  };

  like $@, qr/The filter property is required for the Prefer::GoodVersion plugin/;

};

subtest 'filters out string version' => sub {

  alienfile_ok q{
    use alienfile;
    share {
      plugin 'Fetch::Foo' => [ qw( 1.2.3 1.2.4 1.2.5 ) ];
      plugin 'Prefer::SortVersions';
      plugin 'Prefer::GoodVersion' => '1.2.4';
    };
  };

  my $file = alien_download_ok;
  is(path($file)->slurp, "data:foo-1.2.4.tar.gz");

};

subtest 'filters out list version' => sub {

  alienfile_ok q{
    use alienfile;
    share {
      plugin 'Fetch::Foo' => [ qw( 1.2.3 1.2.4 1.2.5 ) ];
      plugin 'Prefer::SortVersions';
      plugin 'Prefer::GoodVersion' => ['1.2.4', '1.2.3'];
    };
  };

  my $file = alien_download_ok;
  is(path($file)->slurp, "data:foo-1.2.4.tar.gz");

};

subtest 'filters out code ref' => sub {

  alienfile_ok q{
    use alienfile;
    share {
      plugin 'Fetch::Foo' => [ qw( 1.2.3 1.2.4 1.2.5 ) ];
      plugin 'Prefer::SortVersions';
      plugin 'Prefer::GoodVersion' => sub {
        my($file) = @_;
        $file->{version} eq '1.2.4';
      };
    };
  };

  my $file = alien_download_ok;
  is(path($file)->slurp, "data:foo-1.2.4.tar.gz");


};

done_testing;