Bracket
view release on metacpan or search on metacpan
t/lib/BracketTestSchema.pm view on Meta::CPAN
# if add_drop_table has been specified, it will try to drop tables beforehand, but not "IF EXISTS",
# due to a BUG in SQL::Translator: https://rt.cpan.org/Ticket/Display.html?id=48688
# This will cause failures if the tables don't exist (i.e. when you first deploy):
# ("DBI Exception: DBD::$driver::db do failed: no such table")
#
#-mxh This is fragile because it relies on fixed output in the regex.
# Recently, the output changed to include a "\n" and broke this code.
# I added the s (and i) regex modifiers, but it still needs a better implementation.
local $SIG{__WARN__} = sub {
die @_ unless $_[0] =~ /no such table.*DROP TABLE/is;
};
$schema->deploy($attrs);
$self->populate_schema($schema) if $args{populate};
my $config = {
name => 'Bracket Test Suite',
'Model::DBIC' => { connect_info => $schema->storage->connect_info, },
authentication => {
default_realm => 'members',
realms => {
members => {
credential => {
class => 'Password',
password_field => 'password',
password_type => 'self_check',
},
store => {
class => 'DBIx::Class',
user_model => 'DBIC::Player',
role_relation => 'roles',
role_field => 'role',
use_userdata_from_session => 1,
},
},
}
},
'Plugin::Session' => {
dbic_class => 'DBIC::Session',
expires => 604800,
},
};
YAML::DumpFile('t/var/bracket.yml', $config);
return $schema;
}
=head2 populate_schema
BracketTestSchema->populate_schema( $schema );
After deploying the schema, we can use this method to populate
the tables with test data: ...
=cut
sub populate_schema {
my $self = shift;
my $schema = shift;
$schema->storage->dbh->do("PRAGMA synchronous = OFF");
$schema->storage->ensure_connected;
$schema->create_initial_data;
#$self->create_test_data($schema);
}
=head2 create_test_data
Populate the schema with some test data. For now, path permissions.
=cut
sub create_test_data {
my ($self, $schema) = @_;
my @roles = $schema->resultset('Role')->search();
}
1;
( run in 0.554 second using v1.01-cache-2.11-cpan-39bf76dae61 )