1234567891011121314151617181920212223242526272829303132 |
- use strict;
- use warnings;
- use Test::More;
- use Test::MockModule qw{strict};
- use Test::Deep;
- use Test::Fatal qw{exception};
- use FindBin;
- use lib "$FindBin::Bin/../lib";
- use Test::MockFile;
- require_ok('Trog::Config') or BAIL_OUT("Can't find SUT");
- subtest 'theme_dir' => sub {
- my $cust_cfg = Test::MockFile->file("config/main.cfg");
- my $mocked_cfg = Test::MockFile->file( "config/default.cfg", "[general]\ntheme=zippy\n" );
- my @mocked_dirs = map { Test::MockFile->new_dir($_) } qw{www www/themes www/themes/zippy};
- is( Trog::Config::theme_dir(), "themes/zippy", "Got expected theme_dir when directory existent" );
- pop @mocked_dirs;
- is( Trog::Config::theme_dir(), "themes/zippy", "Caching works" ); # would die if this did not
- unlink "config/default.cfg"; # The mocker ain't terribly smart. Maybe a bug?
- undef $mocked_cfg;
- $mocked_cfg = Test::MockFile->file( "config/default.cfg", "[general]\ntheme=dippy\n" );
- push @mocked_dirs, Test::MockFile->dir( "www/themes/dippy" );
- is( Trog::Config::theme_dir(1), "", "Got expected theme_dir when directory not existent and cache popped" );
- };
- # So far no test for get, but the above actually exercises most of it anyways, so eh
- done_testing();
|