Boris Sukholitko > Test-TempDatabase > Test::TempDatabase

Download:
Test-TempDatabase-0.16.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.16   Source  

NAME ^

Test::TempDatabase - temporary database creation and destruction.

SYNOPSIS ^

  use Test::TempDatabase;
  
  my $td = Test::TempDatabase->create(dbname => 'temp_db');
  my $dbh = $td->handle;

  ... some tests ...
  # Test::TempDatabase drops database

DESCRIPTION ^

This module automates creation and dropping of test databases.

USAGE ^

Create test database using Test::TempDatabase->create. Use handle to get a handle to the database. Database will be automagically dropped when Test::TempDatabase instance goes out of scope.

$class->become_postgres_user

When running as root, this function becomes different user. It decides on the user name by probing TEST_TEMP_DB_USER, SUDO_USER environment variables. If these variables are empty, default "postgres" user is used.

create

Creates temporary database. It will be dropped when the resulting instance will go out of scope.

Arguments are passed in as a keyword-value pairs. Available keywords are:

dbname: the name of the temporary database.

rest: the rest of the database connection string. It can be used to connect to a different host, etc.

username, password: self-explanatory.

BUGS ^

* Works with PostgreSQL database currently.

AUTHOR ^

        Boris Sukholitko
        boriss@gmail.com

COPYRIGHT ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO ^

Test::More

syntax highlighting: