Debian Codegraph @

t/app/use_index.t

raw
1 use strict;
2 use warnings;
3 use FindBin;
4 use lib "$FindBin::Bin/../../";
5 use Test::More;
6 use t::Util;
7
8 plan skip_all => "requires \$ENV{PERL_PRNQL_TEST_NETWORK} to test" unless $ENV{PERL_PRNQL_TEST_NETWORK};
9
10 plan skip_all => "requires CPAN::Common::Index" unless eval "require CPAN::Common::Index";
11
12 test_app('exclude submodules', sub {
13 my $tmpdir = shift;
14
15 test_file("$tmpdir/MyTest.pm", <<'END');
16 use strict;
17 use warnings;
18 use Acme::CPANAuthors;
19 use Acme::CPANAuthors::Utils;
20 END
21 }, {use_index => "Mirror"}, { runtime => { requires => { strict => 0, warnings => 0, 'Acme::CPANAuthors' => 0 }}});
22
23 test_app('modules under different namespaces that belong to the same distribution', sub {
24 my $tmpdir = shift;
25
26 test_file("$tmpdir/MyTest.pm", <<'END');
27 use Mojo::Base;
28 END
29
30 test_file("$tmpdir/MyTest2.pm", <<'END');
31 use Mojolicious;
32 END
33 }, {use_index => "Mirror"}, { runtime => { requires => { 'Mojolicious' => 0 }}});
34
35 test_app('modules under different namespaces that belong to the same distribution without a main module', sub {
36 my $tmpdir = shift;
37
38 test_file("$tmpdir/MyTest.pm", <<'END');
39 use LWP::UserAgent;
40 END
41
42 test_file("$tmpdir/MyTest2.pm", <<'END');
43 use LWP::Simple;
44 END
45 }, {use_index => "Mirror"}, { runtime => { requires => { 'LWP::Simple' => 0 }}});
46
47 test_app('modules under different namespaces (same depth) that belong to the same distribution', sub {
48 my $tmpdir = shift;
49
50 test_file("$tmpdir/MyTest.pm", <<'END');
51 use Mojo::Base;
52 END
53
54 test_file("$tmpdir/MyTest2.pm", <<'END');
55 use Mojolicious::Lite;
56 END
57 }, {use_index => "Mirror"}, { runtime => { requires => { 'Mojolicious' => 0 }}});
58
59 test_app('versioned modules', sub {
60 my $tmpdir = shift;
61
62 test_file("$tmpdir/MyTest.pm", <<'END');
63 use Mojo::Base 7.00;
64 END
65
66 test_file("$tmpdir/MyTest2.pm", <<'END');
67 use Mojolicious::Lite 8.00;
68 END
69 }, {use_index => "Mirror"}, { runtime => { requires => { 'Mojo::Base' => '7.00', 'Mojolicious::Lite' => '8.00' }}});
70
71 test_app('versioned module plus unversioned', sub {
72 my $tmpdir = shift;
73
74 test_file("$tmpdir/MyTest.pm", <<'END');
75 use Mojo::Base;
76 END
77
78 test_file("$tmpdir/MyTest2.pm", <<'END');
79 use Mojolicious::Lite 8.00;
80 END
81 }, {use_index => "Mirror"}, { runtime => { requires => { 'Mojolicious::Lite' => '8.00' }}});
82
83 done_testing;