File: errors.t

package info (click to toggle)
libdist-zilla-plugin-metaprovides-package-perl 2.004003-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 360 kB
  • sloc: perl: 421; makefile: 2
file content (173 lines) | stat: -rw-r--r-- 3,123 bytes parent folder | download | duplicates (3)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
use strict;
use warnings;

use Test::More 0.96;
use Test::Fatal;
use Test::Moose;
use Path::Tiny qw( path );
use Test::DZil qw( simple_ini Builder );

my $test_document = <<'EOF';
use strict;
use warnings;

package DZ2;

# ABSTRACT: this is a sample package for testing Dist::Zilla;

sub main {
  return 1;
}

1;

__END__

=head1 NAME

DZ2

=cut
EOF

{
  my $tzil = Builder->from_config(
    { dist_root => 'invalid' },
    {
      add_files => {
        path('source/lib/DZ2.pm') => $test_document,
        path('source/dist.ini')   => simple_ini(
          'GatherDir',    #
          [
            'MetaProvides::Package' => {
              inherit_version => 0,           #
              inherit_missing => 1,           #
              finder          => 'MiSsInG',
            }
          ]

        ),
      },
    },
  );

  $tzil->chrome->logger->set_debug(1);

  my $plugin;

  is(
    exception {
      $plugin = $tzil->plugin_named('MetaProvides::Package');
    },
    undef,
    'Found MetaProvides::Package'
  );
  my $ex;
  isnt(
    $ex = exception {
      $plugin->metadata
    },
    undef,
    'Missing finders die'
  );
}
{
  my $tzil = Builder->from_config(
    { dist_root => 'invalid' },
    {
      add_files => {
        path('source/lib/DZ2.pm') => $test_document,
        path('source/dist.ini')   => simple_ini(
          'GatherDir',    #
          [
            'MetaProvides::Package' => {
              inherit_version => 0,             #
              inherit_missing => 1,             #
              finder          => 'GatherDir',
            }
          ]

        ),
      },
    },
  );

  $tzil->chrome->logger->set_debug(1);

  my $plugin;

  is(
    exception {
      $plugin = $tzil->plugin_named('MetaProvides::Package');
    },
    undef,
    'Found MetaProvides::Package'
  );
  my $ex;
  isnt(
    $ex = exception {
      $plugin->metadata
    },
    undef,
    'Non-finders passed as finders die'
  );
}
{
  {
    package Dist::Zilla::Plugin::FakeFileFinder::File;
    use Moose;

    sub name {
      return "bad";
    }

    package Dist::Zilla::Plugin::FakeFileFinder;
    use Moose;
    with 'Dist::Zilla::Role::FileFinder';

    sub find_files {
      return [ bless {}, __PACKAGE__ . "::File" ];
    }
  }
  my $tzil = Builder->from_config(
    { dist_root => 'invalid' },
    {
      add_files => {
        path('source/lib/DZ2.pm') => $test_document,
        path('source/dist.ini')   => simple_ini(
          'GatherDir',    #
          'FakeFileFinder',
          [
            'MetaProvides::Package' => {
              inherit_version => 0,                  #
              inherit_missing => 1,                  #
              finder          => 'FakeFileFinder',
            }
          ],
        ),
      },
    },
  );

  $tzil->chrome->logger->set_debug(1);

  my $plugin;

  is(
    exception {
      $plugin = $tzil->plugin_named('MetaProvides::Package');
    },
    undef,
    'Found MetaProvides::Package'
  );
  my $ex;
  isnt(
    $ex = exception {
      $plugin->metadata
    },
    undef,
    'finders returning non-files die'
  );
}

done_testing;