8 use Scalar::Util; # load before we break require()
9 use Carp (); # Carp is not used in the test, but we want to have it loaded for proper %INC comparison
11 # a dummy test which lazy-loads more modules (so we can compare INC below)
14 # record contents of %INC - makes sure there are no extra deps slipping into
16 my $inc_before = [ keys %INC ];
17 ok ( (! grep { $_ =~ m|DBIx/Class| } @$inc_before ), 'Nothing DBIC related is yet loaded');
19 # DBIx::Class::Optional::Dependencies queries $ENV at compile time
20 # to build the optional requirements
22 $ENV{DBICTEST_PG_DSN} = '1';
23 delete $ENV{DBICTEST_ORA_DSN};
26 use_ok 'DBIx::Class::Optional::Dependencies';
28 my $inc_after = [ keys %INC ];
32 [ sort (@$inc_before, 'DBIx/Class/Optional/Dependencies.pm') ],
33 'Nothing loaded other than DBIx::Class::OptDeps',
36 my $sqlt_dep = DBIx::Class::Optional::Dependencies->req_list_for ('deploy');
39 [ 'SQL::Translator' ],
40 'Correct deploy() dependency list',
43 # make module loading impossible, regardless of actual libpath contents
45 local @INC = (sub { die('Optional Dep Test') } );
48 ! DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'),
49 'deploy() deps missing',
53 DBIx::Class::Optional::Dependencies->req_missing_for ('deploy'),
54 qr/^SQL::Translator \>\= \d/,
55 'expected missing string contents',
59 DBIx::Class::Optional::Dependencies->req_errorlist_for ('deploy')->{'SQL::Translator'},
60 qr/Optional Dep Test/,
61 'custom exception found in errorlist',
65 #make it so module appears loaded
66 $INC{'SQL/Translator.pm'} = 1;
67 $SQL::Translator::VERSION = 999;
70 ! DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'),
71 'deploy() deps missing cached properly',
75 %DBIx::Class::Optional::Dependencies::req_availability_cache = ();
79 DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'),
80 'deploy() deps present',
84 DBIx::Class::Optional::Dependencies->req_missing_for ('deploy'),
86 'expected null missing string',
90 DBIx::Class::Optional::Dependencies->req_errorlist_for ('deploy'),
92 'expected empty errorlist',
95 # test multiple times to find autovivification bugs
98 DBIx::Class::Optional::Dependencies->req_list_for();
99 } qr/\Qreq_list_for() expects a requirement group name/,
100 "req_list_for without groupname throws exception on run $_";
103 DBIx::Class::Optional::Dependencies->req_list_for('');
104 } qr/\Qreq_list_for() expects a requirement group name/,
105 "req_list_for with empty groupname throws exception on run $_";
108 DBIx::Class::Optional::Dependencies->req_list_for('invalid_groupname');
109 } qr/Requirement group 'invalid_groupname' does not exist/,
110 "req_list_for with invalid groupname throws exception on run $_";
114 DBIx::Class::Optional::Dependencies->req_list_for('rdbms_pg'),
117 }, 'optional dependencies for deploying to Postgres ok');
120 DBIx::Class::Optional::Dependencies->req_list_for('test_rdbms_pg'),
122 $^O ne 'MSWin32' ? ('Sys::SigAction' => '0') : (),
123 'DBD::Pg' => '2.009002',
124 }, 'optional dependencies for testing Postgres with ENV var ok');
127 DBIx::Class::Optional::Dependencies->req_list_for('test_rdbms_oracle'),
128 {}, 'optional dependencies for testing Oracle without ENV var ok');