-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathutil-looks-like.t
74 lines (65 loc) · 2.4 KB
/
util-looks-like.t
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
use Test2::V0;
use App::Perlbrew::Util qw(looks_like_url_of_skaji_relocatable_perl looks_like_sys_would_be_compatible_with_skaji_relocatable_perl);
subtest "looks_like_url_of_skaji_relocatable_perl", sub {
is(
looks_like_url_of_skaji_relocatable_perl($_),
hash {
field url => string($_);
field version => string('5.40.0.0');
field os => in_set(
string('darwin'),
string('linux'),
);
field arch => string("amd64");
field original_filename => match(qr/^perl-(.+?)-amd64\.tar\.gz$/);
end();
},
"positive case: $_"
) for qw(
https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-darwin-amd64.tar.gz
https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-amd64.tar.gz
);
is(looks_like_url_of_skaji_relocatable_perl($_), F(), "negative case: $_")
for qw(
https://example.com/
https://gugod.org/
https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-x86_64.tar.gz
);
};
subtest "looks_like_sys_would_be_compatible_with_skaji_relocatable_perl", sub {
my $detail = looks_like_url_of_skaji_relocatable_perl("https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-amd64.tar.gz");
my @positiveCases = (
(mock {} =>
add => [
os => sub { "linux" },
arch => sub { "amd64" },
]),
(mock {} =>
add => [
os => sub { "linux" },
arch => sub { "x86_64" },
]),
);
my @negativeCasse = (
(mock {} =>
add => [
os => sub { "linux" },
arch => sub { "arm64" },
]),
(mock {} =>
add => [
os => sub { "darwin" },
arch => sub { "aarch64" },
]),
(mock {} =>
add => [
os => sub { "darwin" },
arch => sub { "x86_64" },
]),
);
is looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $_), T()
for @positiveCases;
is looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $_), F()
for @negativeCasse;
};
done_testing;