The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::SQLite - SQLite setup/teardown for tests

VERSION

version 0.0104

SYNOPSIS

  use DBI;
  use Test::SQLite;

  my $sqlite = Test::SQLite->new(
    database => '/some/where/production.db',
  );

  my $dbh = DBI->connect($sqlite->dsn, '', '');

  $sqlite = Test::SQLite->new(
    schema => '/some/where/schema.sql',
  );

  $dbh = $sqlite->dbh;

DESCRIPTION

Test::SQLite is loosely inspired by Test::PostgreSQL and Test::mysqld, and creates a temporary db to use in tests. Unlike those modules, it is limited to setup/teardown of the test db given a database or schema SQL file. Also this module will return the database dbh handle and dsn connection string.

ATTRIBUTES

database

The database to copy.

has_database

Boolean indicating that a database file was provided to the constructor.

schema

The SQL schema to create a test database.

has_schema

Boolean indicating that a schema file was provided to the constructor.

dsn

The database connection string.

dbh

A connected database handle.

METHODS

new

  $sqlite = Test::SQLite->new(%arguments);

Create a new Test::SQLite object.

BUILD

Ensure that we are not given both a database and a schema.

THANK YOU

Kaitlyn Parkhurst <symkat@symkat.com>

SEE ALSO

DBI

File::Copy

File::Temp

Moo

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Gene Boggs.

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