Tyler MacDonald > DBIx-Migration-Directories-0.11 > DBIx::Migration::Directories::Test

Download:
DBIx-Migration-Directories-0.11.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: DBIx-Migration-Directories-0.12

NAME ^

DBIx::Migration::Directories::Test - Convienence class for unit tests

SYNOPSIS ^

  use Test::More;
  use DBIx::Transaction;

  {
    package My::Schema::Test;
    use base qw(
      My::Schema DBIx::Migration::Directories::Test
    );
  }

  my $dbh =
    eval { DBIx::Transaction->connect('DBI:mysql:dbname=test', 'root', '') }
    or plan skip_all => "Could not connect to database: $@";

  my $migration = My::Schema::Test->new_test(
    dir => 'schema/mysql', dbh => $dbh,
    schema => 'My::Schema',
    tests => [
      sub {
        ok(
          $dbh->do(q{
            INSERT INTO mytable (my_time) VALUES (now())
          }),
          "insert an item stub into the database"
        );
      }
    ]
  );

  plan tests => $migration->num_tests;
  $migration->run_tests;

DESCRIPTION ^

This is a very simple wrapper around DBIx::Migration::Directories to assist with running unit tests. It installs your schema before running tests, and removes it after. It will skip running your tests if the schema is already installed. If your tests crash, it will attempt to uninstall the schema.

For more information, view the source. It's pretty short.

AUTHOR ^

Tyler "Crackerjack" MacDonald <japh@crackerjack.net>

LICENSE ^

Copyright 2009 Tyler "Crackerjack" MacDonald <japh@crackerjack.net>

This is free software; You may distribute it under the same terms as perl itself.

SEE ALSO ^

DBIx::Migration::Directories

syntax highlighting: