Create a gist now

Instantly share code, notes, and snippets.

@fibo /oracle.t
Last active May 11, 2016

What would you like to do?
Test Oracle connection
# [Gist](https://gist.github.com/fibo/5901819)
#
## How to launch
# $ prove oracle.t
use strict;
use warnings;
use DBI;
use File::Spec;
use Test::More;
my $user = 'scott'; # Change me
my $pass = 'tiger'; # Change me
my $conn = 'DBI:Oracle:testdb'; # Change me
ok $ENV{ORACLE_BASE}, '$ORACLE_BASE env var is defined';
ok $ENV{ORACLE_HOME}, '$ORACLE_HOME env var is defined';
ok $ENV{TNS_ADMIN}, '$TNS_ADMIN env var is defined';
ok -d $ENV{ORACLE_BASE}, '$ORACLE_BASE dir exists';
ok -d $ENV{ORACLE_HOME}, '$ORACLE_HOME dir exists';
ok -e File::Spec->catfile($ENV{TNS_ADMIN}, 'tnsnames.ora'), 'tnsnames.ora exists';
ok my $dbh = DBI->connect($conn, $user, $pass,{ PrintError => 1, }), 'database connection';
done_testing
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment