0.14 release, Changes updated, tests fixed
[catagits/Catalyst-Model-DBIC-Schema.git] / t / 05testapp.t
CommitLineData
5d11d759 1use strict;
2use Test::More;
3use FindBin;
4use File::Spec;
5use File::Find;
6
7plan skip_all => 'Enable this optional test with $ENV{C_M_DBIC_SCHEMA_TESTAPP}'
8 unless $ENV{C_M_DBIC_SCHEMA_TESTAPP};
9
12ee1738 10# XXX this test needs a re-write to fully test the current set of capabilities...
11
5d11d759 12my $test_params = [
13 [ 'TestSchema', 'DBIC::Schema', '' ],
0b2a7108 14 [ 'TestSchemaDSN', 'DBIC::Schema', q{fakedsn fakeuser fakepass '{ AutoCommit => 1 }'} ],
5d11d759 15];
16
17plan tests => (2 * @$test_params);
18
19my $test_dir = $FindBin::Bin;
20my $blib_dir = File::Spec->catdir ($test_dir, '..', 'blib', 'lib');
21my $cat_dir = File::Spec->catdir ($test_dir, 'TestApp');
22my $catlib_dir = File::Spec->catdir ($cat_dir, 'lib');
23my $creator = File::Spec->catfile($cat_dir, 'script', 'testapp_create.pl');
24my $model_dir = File::Spec->catdir ($catlib_dir, 'TestApp', 'Model');
25
26chdir($test_dir);
27system("catalyst.pl TestApp");
28chdir($cat_dir);
29
30foreach my $tparam (@$test_params) {
31 my ($model, $helper, $args) = @$tparam;
12ee1738 32 system("$^X -I$blib_dir $creator model $model $helper $model $args");
5d11d759 33 my $model_path = File::Spec->catfile($model_dir, $model . '.pm');
34 ok( -f $model_path, "$model_path is a file" );
35 my $compile_rv = system("$^X -I$blib_dir -I$catlib_dir -c $model_path");
36 ok($compile_rv == 0, "perl -c $model_path");
37}
38
39chdir($test_dir);
40
41sub rm_rf {
42 my $name = $File::Find::name;
43 if(-d $name) { rmdir $name or die "Cannot rmdir $name: $!" }
44 else { unlink $name or die "Cannot unlink $name: $!" }
45}
46finddepth(\&rm_rf, $cat_dir);