App-GitHooks-Plugin-PgBouncerAuthSyntax
view release on metacpan or search on metacpan
{
'userlist.txt' => qq|"user" "password"\n|
. qq|; A commment\n|
. qq|"user" "password"\n|,
},
expected => qr/x The PgBouncer syntax is correct/,
},
{
comments_setting => 'disallow',
name => 'Prevent comment lines at the end of the file (comments_setting=disallow).',
files =>
{
'userlist.txt' => qq|"user" "password"\n|
. qq|"user" "password"\n|
. qq|; A commment\n|,
},
expected => qr/x The PgBouncer syntax is correct/,
},
{
comments_setting => 'disallow',
name => 'Prevent comment lines not at the end of the file (comments_setting=disallow).',
files =>
{
'userlist.txt' => qq|"user" "password"\n|
. qq|; A commment\n|
. qq|"user" "password"\n|,
},
expected => qr/x The PgBouncer syntax is correct/,
},
];
# 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 => 0,
config => "[PgBouncerAuthSyntax]\n"
. "file_pattern = /\Quserlist.txt\E\$/\n"
. "comments_setting = $test->{'comments_setting'}\n"
. "\n",
hooks => [ 'pre-commit' ],
plugins => [ 'App::GitHooks::Plugin::PgBouncerAuthSyntax' ],
);
# 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 3.775 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )