fixed sql mistakes from hierarchical query tests
[dbsrgits/DBIx-Class.git] / t / 10optional_deps.t
CommitLineData
05c0614b 1use strict;
2use warnings;
3no warnings qw/once/;
4
5use Test::More;
6use lib qw(t/lib);
7use Scalar::Util; # load before we break require()
8
9use_ok 'DBIx::Class::Optional::Dependencies';
10
11my $sqlt_dep = DBIx::Class::Optional::Dependencies->req_list_for ('deploy');
12is_deeply (
13 [ keys %$sqlt_dep ],
14 [ 'SQL::Translator' ],
15 'Correct deploy() dependency list',
16);
17
18# make module loading impossible, regardless of actual libpath contents
19@INC = (sub { die('Optional Dep Test') } );
20
21ok (
22 ! DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'),
23 'deploy() deps missing',
24);
25
26like (
27 DBIx::Class::Optional::Dependencies->req_missing_for ('deploy'),
28 qr/^SQL::Translator \>\= \d/,
29 'expected missing string contents',
30);
31
32like (
33 DBIx::Class::Optional::Dependencies->req_errorlist_for ('deploy')->{'SQL::Translator'},
34 qr/Optional Dep Test/,
35 'custom exception found in errorlist',
36);
37
38
39#make it so module appears loaded
40$INC{'SQL/Translator.pm'} = 1;
41$SQL::Translator::VERSION = 999;
42
43ok (
44 ! DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'),
45 'deploy() deps missing cached properly',
46);
47
48#reset cache
49%DBIx::Class::Optional::Dependencies::req_availability_cache = ();
50
51
52ok (
53 DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'),
54 'deploy() deps present',
55);
56
57is (
58 DBIx::Class::Optional::Dependencies->req_missing_for ('deploy'),
59 '',
60 'expected null missing string',
61);
62
63is_deeply (
64 DBIx::Class::Optional::Dependencies->req_errorlist_for ('deploy'),
65 {},
66 'expected empty errorlist',
67);
68
69
70done_testing;