| 1 | package DBIO::SQLite::Test; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: SQLite-specific test utilities for DBIO | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 219 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 219 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 219 | ▶ | use DBIO::Test; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 219 | ▶ | use DBIO::Test::Schema; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 219 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 219 | ▶ | use DBIO::Util qw(dir_path parent_dir mkpath); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 219 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 219 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # Delegate :DiffSQL and other exports to DBIO::Test | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 219 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||
| 19 | # Manually re-export into caller's namespace | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 40 | for my $exp (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 21 | 40 | ▶ | if ($exp eq ':DiffSQL') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 40 | require DBIO::SQLMaker; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 40 | require SQL::Abstract::Test; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 40 | for (qw(is_same_sql_bind is_same_sql is_same_bind)) { | |||||||||||||||||||||||||||||||||||||||||
| 25 | 219 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 120 | *{"${caller}::$_"} = \&{"SQL::Abstract::Test::$_"}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | elsif ($exp eq ':GlobalLock') { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # GlobalLock is a no-op in the DBIO test suite — the original | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # DBIOTest locking mechanism is not needed outside of the old | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # concurrent test infrastructure. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | croak "Unknown export $exp requested from $self"; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 219 | my $dir; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 286 | ▶ | sub _vardir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vardir: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 286 | ▶ | return $dir if $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 219 | $dir = dir_path( | |||||||||||||||||||||||||||||||||||||||||
| 46 | parent_dir(parent_dir(parent_dir(parent_dir(__FILE__)))), | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 't', 'var', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 219 | ▶ | mkpath($dir) unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 219 | return $dir; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 219 | ▶ | sub _sqlite_dbfilename { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sqlite_dbfilename: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 286 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 286 | ▶ | my $holder = $ENV{DBIO_TEST_LOCK_HOLDER} || $$; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ENV{'DBIO_TEST_LOCK_HOLDER'} || $$
MC/DC0%0/2
$ENV{'DBIO_TEST_LOCK_HOLDER'} || $$
$ENV{'DBIO_TEST_LOCK_HOLDER'}
$$
Truth table66%2/3
A || B
A= $ENV{'DBIO_TEST_LOCK_HOLDER'}B= $$
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 286 | ▶ | $holder = $$ if $holder == -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 286 | return _vardir() . "/DBIOTest-$holder.db"; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 401 | ▶ | sub _sqlite_dbname { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sqlite_dbname: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 401 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 401 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | return $self->_sqlite_dbfilename if ( | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 401 | ▶ | defined $args{sqlite_use_file} ? $args{sqlite_use_file} : $ENV{'DBIO_TEST_SQLITE_USE_FILE'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 336 | return ":memory:"; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 400 | ▶ | sub _database { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_database: called CC=6 SCAR=20.3
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 400 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 400 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 400 | ▶ | if ($ENV{DBIO_TEST_DSN}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | (map { $ENV{"DBIO_TEST_${_}"} // '' } qw/DSN DBUSER DBPASS/), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"DBIO_TEST_$_"} // ""
MC/DC0%0/1
$ENV{"DBIO_TEST_$_"} // ""
$ENV{"DBIO_TEST_$_"}
Truth table0%0/2
A
A= $ENV{"DBIO_TEST_$_"}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | { AutoCommit => 1, %args }, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 400 | my $db_file = $self->_sqlite_dbname(%args); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 400 | for ($db_file, "${db_file}-journal") { | |||||||||||||||||||||||||||||||||||||||||
| 87 | 800 | ▶ | next unless -e $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 32 | ▶ | unlink ($_) or carp ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | "Unable to unlink existing test database file $_ ($!), " | ||||||||||||||||||||||||||||||||||||||||||
| 90 | . "creation of fresh database / further tests may fail!" | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | return ("dbi:SQLite:${db_file}", '', '', { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | AutoCommit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 417 | ▶ | on_connect_do => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 417 | my $storage = shift; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 417 | my $dbh = $storage->_get_dbh; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 417 | $dbh->do('PRAGMA synchronous = OFF'); | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 416 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"DBIO_TEST_SQLITE_REVERSE_DEFAULT_ORDER"} and $storage->_server_info->{"normalized_dbms_version"} >= "3.007009"
MC/DC0%0/2
$ENV{"DBIO_TEST_SQLITE_REVERSE_DEFAULT_ORDER"} and $storage->_server_info->{"normalized_dbms_version"} >= "3.007009"
$ENV{"DBIO_TEST_SQLITE_REVERSE_DEFAULT_ORDER"}
$storage->_server_info->{"normalized_dbms_version"} >= "3.007009"
Truth table33%1/3
A and B
A= $ENV{"DBIO_TEST_SQLITE_REVERSE_DEFAULT_ORDER"}B= $storage->_server_info->{"normalized_dbms_version"} >= "3.007009"
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | $ENV{DBIO_TEST_SQLITE_REVERSE_DEFAULT_ORDER} | ||||||||||||||||||||||||||||||||||||||||||
| 103 | and | ||||||||||||||||||||||||||||||||||||||||||
| 104 | $storage->_server_info->{normalized_dbms_version} >= 3.007009 | ||||||||||||||||||||||||||||||||||||||||||
| 105 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $dbh->do('PRAGMA reverse_unordered_selects = ON'); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 400 | %args, | |||||||||||||||||||||||||||||||||||||||||
| 110 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 389 | ▶ | sub init_schema { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_schema: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 389 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 389 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 389 | %args = %{ DBIO::Test->normalize_init_schema_args(\%args) }; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 389 | my $schema; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 389 | ▶ | if ($args{compose_connection}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $schema = DBIO::Test::Schema->compose_connection( | |||||||||||||||||||||||||||||||||||||||||
| 123 | 'DBIO::Test', $self->_database(%args) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 389 | $schema = DBIO::Test::Schema->compose_namespace('DBIO::Test'); | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 389 | ▶ | if ($args{storage_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | $schema->storage_type($args{storage_type}); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 389 | ▶ | if (!$args{no_connect}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 388 | $schema = $schema->connect($self->_database(%args)); | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 388 | ▶ | if ($args{replicant_connect_info} && $schema->storage->isa('DBIO::Replicated::Storage')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"replicant_connect_info"} and $schema->storage->isa("DBIO::Replicated::Storage")
MC/DC50%1/2
$args{"replicant_connect_info"} and $schema->storage->isa("DBIO::Replicated::Storage")
$args{"replicant_connect_info"}
$schema->storage->isa("DBIO::Replicated::Storage")
Truth table66%2/3
A and B
A= $args{"replicant_connect_info"}B= $schema->storage->isa("DBIO::Replicated::Storage")
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | $schema->storage->connect_replicants(@{ $args{replicant_connect_info} }); | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 389 | ▶ | if (!$args{no_deploy}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 334 | DBIO::Test->deploy_schema($schema, $args{deploy_args}); | |||||||||||||||||||||||||||||||||||||||||
| 143 | DBIO::Test->populate_schema($schema) | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 334 | ▶ | unless $args{no_populate}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 389 | return $schema; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 219 | ▶ | sub _cleanup_dbfile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup_dbfile: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 219 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 219 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $ENV{"DBIO_TEST_LOCK_HOLDER"} or $ENV{"DBIO_TEST_LOCK_HOLDER"} == -1 or $ENV{"DBIO_TEST_LOCK_HOLDER"} == $$
not $ENV{"DBIO_TEST_LOCK_HOLDER"} or $ENV{"DBIO_TEST_LOCK_HOLDER"} == -1
MC/DC0%0/3
not $ENV{"DBIO_TEST_LOCK_HOLDER"} or $ENV{"DBIO_TEST_LOCK_HOLDER"} == -1 or $ENV{"DBIO_TEST_LOCK_HOLDER"} == $$
not $ENV{"DBIO_TEST_LOCK_HOLDER"}
$ENV{"DBIO_TEST_LOCK_HOLDER"} == -1
$ENV{"DBIO_TEST_LOCK_HOLDER"} == $$
Truth table50%2/4
not(A) or B or C
A= not $ENV{"DBIO_TEST_LOCK_HOLDER"}B= $ENV{"DBIO_TEST_LOCK_HOLDER"} == -1C= $ENV{"DBIO_TEST_LOCK_HOLDER"} == $$
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | ! $ENV{DBIO_TEST_LOCK_HOLDER} | ||||||||||||||||||||||||||||||||||||||||||
| 154 | or | ||||||||||||||||||||||||||||||||||||||||||
| 155 | $ENV{DBIO_TEST_LOCK_HOLDER} == -1 | ||||||||||||||||||||||||||||||||||||||||||
| 156 | or | ||||||||||||||||||||||||||||||||||||||||||
| 157 | $ENV{DBIO_TEST_LOCK_HOLDER} == $$ | ||||||||||||||||||||||||||||||||||||||||||
| 158 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 219 | my $db_file = $self->_sqlite_dbfilename; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 219 | unlink $_ for ($db_file, "${db_file}-journal"); | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 218 | ▶ | END { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 218 | __PACKAGE__->_cleanup_dbfile; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 219 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | DBIO::SQLite::Test - SQLite-specific test utilities for DBIO | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | version 0.900001 | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | use DBIO::SQLite::Test; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # In-memory schema (most tests) | ||||||||||||||||||||||||||||||||||||||||||
| 189 | my $schema = DBIO::SQLite::Test->init_schema; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | # File-based schema (for reconnect/persistence tests) | ||||||||||||||||||||||||||||||||||||||||||
| 192 | my $schema = DBIO::SQLite::Test->init_schema(sqlite_use_file => 1); | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # Shared driver test through replicated storage | ||||||||||||||||||||||||||||||||||||||||||
| 195 | my $replicated = DBIO::SQLite::Test->init_schema( | ||||||||||||||||||||||||||||||||||||||||||
| 196 | replicated => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | storage_type => 'DBIO::SQLite::Storage', | ||||||||||||||||||||||||||||||||||||||||||
| 198 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | Extends L<DBIO::Test> with SQLite-specific test helpers for the | ||||||||||||||||||||||||||||||||||||||||||
| 203 | L<DBIO::SQLite> driver distribution. | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | =head2 _sqlite_dbfilename | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | Returns the path to the file-based test SQLite database. | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | =head2 _sqlite_dbname | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | Returns the database name — either a file path or C<:memory:>. | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | =head2 _database | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | Returns a list of C<($dsn, $user, $pass, \%opts)> suitable for | ||||||||||||||||||||||||||||||||||||||||||
| 218 | C<< $schema->connect() >>. | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | =head2 init_schema | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | my $schema = DBIO::SQLite::Test->init_schema(%opts); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | Wrapper around L<DBIO::Test/init_schema> that defaults to an | ||||||||||||||||||||||||||||||||||||||||||
| 225 | in-memory SQLite database. | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | Supports all L<DBIO::Test/init_schema> options plus: | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | =item sqlite_use_file | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | Use a file-based SQLite database instead of C<:memory:>. | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | Shared L<DBIO::Test> options such as C<replicated =E<gt> 1> are normalized | ||||||||||||||||||||||||||||||||||||||||||
| 238 | before the SQLite-specific connection is built, so driver tests can opt | ||||||||||||||||||||||||||||||||||||||||||
| 239 | into replicated coverage without rebuilding their schema setup. | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | DBIO & DBIx::Class Authors | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | Copyright (C) 2026 DBIO Authors | ||||||||||||||||||||||||||||||||||||||||||
| 248 | Portions Copyright (C) 2005-2025 DBIx::Class Authors | ||||||||||||||||||||||||||||||||||||||||||
| 249 | Based on DBIx::Class, heavily modified. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 252 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | =cut | ||||||||||||||||||||||||||||||||||||||||||