App-GitHooks-Plugin-ValidateChangelogFormat
view release on metacpan or search on metacpan
{
'Changes' => "Release for test package.\n"
. "\n"
. "v1.2.3 2014-01-01 01:00\n"
. " - Test feature.\n",
},
expected => qr|\QRelease 1/1: date '2014-01-01T01:00Z' is not in the recommended format\E|,
},
{
name => 'Pass date format specification in githooksrc.',
config => "[ValidateChangelogFormat]\n"
. 'date_format_regex = /^\d{4}-\d{2}-\d{2}$/' . "\n",
files =>
{
'Changes' => "Release for test package.\n"
. "\n"
. "v1.2.3 2014-01-01\n"
. " - Test feature.\n",
},
expected => qr/o The changelog format matches CPAN::Changes::Spec/,
},
# Make sure that releases contain at least one change.
{
name => 'A release must contain at least one change.',
files =>
{
'Changes' => "Release for test package.\n"
. "\n"
. "v1.2.3 2014-01-01\n"
},
expected => qr|\QRelease 1/1: the release does not contain a description of changes\E|,
},
];
# Bail out if Git isn't available.
test_requires_git();
plan( tests => scalar( @$tests ) );
foreach my $test ( @$tests )
{
subtest(
$test->{'name'},
sub
{
plan( tests => 4 );
my $repository = ok_setup_repository(
cleanup_test_repository => 1,
config => $test->{'config'},
hooks => [ 'pre-commit' ],
plugins => [ 'App::GitHooks::Plugin::ValidateChangelogFormat' ],
);
# Set up test files.
ok_add_files(
files => $test->{'files'},
repository => $repository,
);
# Try to commit.
my $stderr;
lives_ok(
sub
{
$stderr = Capture::Tiny::capture_stderr(
sub
{
$repository->run( 'commit', '-m', 'Test message.' );
}
);
note( $stderr );
},
'Commit the changes.',
);
like(
$stderr,
$test->{'expected'},
"The output matches expected results.",
);
}
);
}
( run in 1.850 second using v1.01-cache-2.11-cpan-98e64b0badf )