SHARE
TWEET

Untitled

a guest Jun 18th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use 5.026;
  2. use Test2::V0;
  3. use Data::Dumper::Concise qw< Dumper >;
  4.  
  5. use DBIx::Class::Migration;
  6. use Path::Tiny qw< tempdir >;
  7. use Test::mysqld;
  8.  
  9. my $mysqld = Test::mysqld->new(
  10.     my_cnf => {
  11.         "skip-networking" => "",    # no TCP socket
  12.     },
  13. ) or plan skip_all => $Test::mysqld::errstr;
  14.  
  15. package DB {
  16.     use parent qw< DBIx::Class::Schema >;
  17.     our $VERSION = 1;
  18.     __PACKAGE__->load_namespaces();
  19.     __PACKAGE__->load_components(qw< TableNames >);
  20. };
  21.  
  22. subtest "dbic-migration" => sub {
  23.     my @connect_args = ( $mysqld->dsn(), { RaiseError => 1 } );
  24.     my $target_dir   = tempdir();
  25.  
  26.     ok( my $migration = DBIx::Class::Migration->new(
  27.             dbic_dh_args => { force_overwrite => 1 },
  28.             schema_class => "DB",
  29.             schema_args  => [@connect_args],
  30.             target_dir   => "$target_dir",
  31.         ),
  32.         "should be able to instantiate an instance",
  33.     );
  34.  
  35.     ok( lives { $migration->status },
  36.         "should be able to check the 'status' of the database" )
  37.         or note($@);
  38.  
  39.     ok( lives { $migration->prepare }, "should be able to 'prepare' the dbic migration" )
  40.         or note($@);
  41.  
  42.     ok( lives { $migration->install_if_needed },
  43.         "should be able to 'install' the dbic migration"
  44.     ) or note($@);
  45.  
  46.     is( [ DB->connect(@connect_args)->table_names ],
  47.         ["dbix_class_deploymenthandler_versions"],
  48.         "should only have the deplyment handler version table",
  49.     );
  50. };
  51.  
  52. done_testing;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top