version bumped, added kwalitee, removed old "first release" notice from pod
[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
10my $test_params = [
11 [ 'TestSchema', 'DBIC::Schema', '' ],
0b2a7108 12 [ 'TestSchemaDSN', 'DBIC::Schema', q{fakedsn fakeuser fakepass '{ AutoCommit => 1 }'} ],
13 [ 'TestSchemaLoader', 'DBIC::SchemaLoader', q{fakedsn fakeuser fakepass '{ AutoCommit => 1 }'} ],
5d11d759 14];
15
16plan tests => (2 * @$test_params);
17
18my $test_dir = $FindBin::Bin;
19my $blib_dir = File::Spec->catdir ($test_dir, '..', 'blib', 'lib');
20my $cat_dir = File::Spec->catdir ($test_dir, 'TestApp');
21my $catlib_dir = File::Spec->catdir ($cat_dir, 'lib');
22my $creator = File::Spec->catfile($cat_dir, 'script', 'testapp_create.pl');
23my $model_dir = File::Spec->catdir ($catlib_dir, 'TestApp', 'Model');
24
25chdir($test_dir);
26system("catalyst.pl TestApp");
27chdir($cat_dir);
28
29foreach my $tparam (@$test_params) {
30 my ($model, $helper, $args) = @$tparam;
0b2a7108 31 my $model_two = $model;
32 if($helper =~ /Loader/) {
33 $model_two = '';
34 }
35 system("$^X -I$blib_dir $creator model $model $helper $model_two $args");
5d11d759 36 my $model_path = File::Spec->catfile($model_dir, $model . '.pm');
37 ok( -f $model_path, "$model_path is a file" );
38 my $compile_rv = system("$^X -I$blib_dir -I$catlib_dir -c $model_path");
39 ok($compile_rv == 0, "perl -c $model_path");
40}
41
42chdir($test_dir);
43
44sub rm_rf {
45 my $name = $File::Find::name;
46 if(-d $name) { rmdir $name or die "Cannot rmdir $name: $!" }
47 else { unlink $name or die "Cannot unlink $name: $!" }
48}
49finddepth(\&rm_rf, $cat_dir);