File: 71_missing_config.t

package info (click to toggle)
libcpan-reporter-perl 1.2020-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,752 kB
  • sloc: perl: 5,440; makefile: 2
file content (78 lines) | stat: -rw-r--r-- 1,947 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
#!perl
use strict;
BEGIN{ if (not $] < 5.006) { require warnings; warnings->import } }

select(STDERR); $|=1;
select(STDOUT); $|=1;

use Test::More;
use lib 't/lib';
use MockCPANDist;
use Helper;
use Frontend;
use Capture::Tiny qw/capture/;

my @test_distros = (
    # pass
    {
        name => 't-Pass',
        eumm_success => 1,
        eumm_grade => "pass",
        eumm_msg => "All tests successful",
        mb_success => 1,
        mb_grade => "pass",
        mb_msg => "All tests successful",
    },
    {
        name => 't-Fail',
        eumm_success => 0,
        eumm_grade => "fail",
        eumm_msg => "One or more tests failed",
        mb_success => 0,
        mb_grade => "fail",
        mb_msg => "One or more tests failed",
    },
);

plan tests => 1 + test_grade_test_plan() * @test_distros + 3;

#--------------------------------------------------------------------------#
# Fixtures
#--------------------------------------------------------------------------#

my $mock_dist = MockCPANDist->new( 
    pretty_id => "JOHNQP/Bogus-Module-1.23.tar.gz",
    prereq_pm       => {
        requires => { 'File::Spec' => 0 },
    },
    author_id       => "JOHNQP",
    author_fullname => "John Q. Public",
);

#--------------------------------------------------------------------------#
# tests
#--------------------------------------------------------------------------#

require_ok('CPAN::Reporter');

# Config file not created in advance with test_config()

for my $case ( @test_distros ) {
    test_grade_test( $case, $mock_dist );
} 

# Test warning messages

my ($stdout, $stderr) = capture {
    CPAN::Reporter::_dispatch_report( {} );
};

like( $stdout, "/couldn't read configuration file/",
    "config file not found warnings"
);
like( $stdout, "/required 'email_from' option missing an email address/", 
    "email address required warning"
);
like( $stdout, "/report will not be sent/",
    "report not sent notice"
);