X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fdeploy.t;h=78e2c8c7a5b3e87103ecbf25b001c4effe08852b;hb=39568b8ae8bbe3cf6b6873ce87a8fd925a539d64;hp=4cc8dff3a30552c6c9273ea7333d7cfa9720ee82;hpb=4068e05f67336c92ee83f71cdd86df10beee014e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/storage/deploy.t b/t/storage/deploy.t index 4cc8dff..78e2c8c 100644 --- a/t/storage/deploy.t +++ b/t/storage/deploy.t @@ -2,31 +2,52 @@ use strict; use warnings; use Test::More; +use Test::Exception; +use Path::Class qw/dir/; use lib qw(t/lib); use DBICTest; -use File::Spec; -use File::Path qw/ mkpath rmtree /; +BEGIN { + require DBIx::Class; + plan skip_all => + 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') +} + +# this is how maint/gen_schema did it (connect() to force a storage +# instance, but no conninfo) +# there ought to be more code like this in the wild +like( + DBICTest::Schema->connect->deployment_statements('SQLite'), + qr/\bCREATE TABLE\b/i +); +lives_ok( sub { + my $parse_schema = DBICTest->init_schema(no_deploy => 1); + $parse_schema->deploy({},'t/lib/test_deploy'); + $parse_schema->resultset("Artist")->all(); +}, 'artist table deployed correctly' ); my $schema = DBICTest->init_schema(); -my $var = File::Spec->catfile(qw| t var create_ddl_dir |); --d $var - or mkpath($var) - or die "can't create $var"; +my $var = dir ("t/var/ddl_dir-$$"); +$var->mkpath unless -d $var; -my $test_dir_1 = File::Spec->catdir( $var, 'test1', 'foo', 'bar' ); -rmtree( $test_dir_1 ) if -d $test_dir_1; +my $test_dir_1 = $var->subdir ('test1', 'foo', 'bar' ); +$test_dir_1->rmtree if -d $test_dir_1; $schema->create_ddl_dir( undef, undef, $test_dir_1 ); -ok( -d $test_dir_1, 'create_ddl_dir did a mkpath on its target dir' ); +ok( -d $test_dir_1, 'create_ddl_dir did a make_path on its target dir' ); ok( scalar( glob $test_dir_1.'/*.sql' ), 'there are sql files in there' ); -TODO: { - local $TODO = 'we should probably add some tests here for actual deployability of the DDL?'; - ok( 0 ); +{ + local $TODO = 'we should probably add some tests here for actual deployability of the DDL?'; + ok( 0 ); +} + +END { + $var->rmtree; } done_testing;