DBIx-Migration
view release on metacpan or search on metacpan
t/lib/Test/PgTAP.pm view on Meta::CPAN
my $sth;
if ( defined $schema ) {
$sth = $Dbh->prepare( <<'EOF' );
SELECT
trigger_name
FROM
information_schema.triggers
WHERE
event_object_schema = ? AND event_object_table = ?
EOF
$sth->execute( $schema, $table );
} else {
$sth = $Dbh->prepare( <<'EOF' );
SELECT
quote_ident( event_object_schema ) || '.' || trigger_name
FROM
information_schema.triggers
WHERE
event_object_schema <> 'pg_catalog' AND event_object_schema <> 'information_schema' AND event_object_table = ?
EOF
$sth->execute( $table );
}
my @got_triggers = map { @$_ } @{ $sth->fetchall_arrayref( [ 0 ] ) };
my ( $ok, $stack ) = cmp_details( \@got_triggers, bag( @$expected_triggers ) );
my $Test = __PACKAGE__->builder;
unless ( defined $test_name ) {
$test_name =
defined $schema
? "Table '$table' in schema '$schema' should have the expected triggers"
: "Table '$table' in non PostgreSQL schemas should have the expected triggers";
}
unless ( $Test->ok( $ok, $test_name ) ) {
my $diag = deep_diag( $stack );
$Test->diag( $diag );
}
}
1;
__END__
=pod
=head1 NAME
Test::pgTAP - Test module that implements pgTAP in Perl
=head1 TEST FUNCTIONS
=head2 SCHEMA RELATED
=head3 C<tables_are()>
=head3 C<triggers_are()>
=head1 SEE ALSO
=over
=item * L<Using pgTAP|https://pgtap.org/documentation.html#usingpgtap>
=back
=cut
( run in 0.869 second using v1.01-cache-2.11-cpan-e1769b4cff6 )