Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use 5.026;
- use Test2::V0;
- use Data::Dumper::Concise qw< Dumper >;
- use DBIx::Class::Migration;
- use Path::Tiny qw< tempdir >;
- use Test::mysqld;
- my $mysqld = Test::mysqld->new(
- my_cnf => {
- "skip-networking" => "", # no TCP socket
- },
- ) or plan skip_all => $Test::mysqld::errstr;
- package DB {
- use parent qw< DBIx::Class::Schema >;
- our $VERSION = 1;
- __PACKAGE__->load_namespaces();
- __PACKAGE__->load_components(qw< TableNames >);
- };
- subtest "dbic-migration" => sub {
- my @connect_args = ( $mysqld->dsn(), { RaiseError => 1 } );
- my $target_dir = tempdir();
- ok( my $migration = DBIx::Class::Migration->new(
- dbic_dh_args => { force_overwrite => 1 },
- schema_class => "DB",
- schema_args => [@connect_args],
- target_dir => "$target_dir",
- ),
- "should be able to instantiate an instance",
- );
- ok( lives { $migration->status },
- "should be able to check the 'status' of the database" )
- or note($@);
- ok( lives { $migration->prepare }, "should be able to 'prepare' the dbic migration" )
- or note($@);
- ok( lives { $migration->install_if_needed },
- "should be able to 'install' the dbic migration"
- ) or note($@);
- is( [ DB->connect(@connect_args)->table_names ],
- ["dbix_class_deploymenthandler_versions"],
- "should only have the deplyment handler version table",
- );
- };
- done_testing;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement