Class-Simple-Cached
view release on metacpan or search on metacpan
t/integration.t view on Meta::CPAN
};
# âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
# Workflow 2 â Optional CHI dependency
#
# Strategy: block CHI with Test::Without::Module to prove that CSC itself
# never issues a `require CHI` â CHI is a purely caller-supplied runtime
# dependency. The module is already loaded and continues to work with a
# hash-ref cache even when CHI cannot be required.
#
# After the subtest, CHI is unblocked so subsequent subtests can load it.
# âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
subtest 'workflow:optional-chi:hash-backend-works-without-chi' => sub {
# Block CHI from loading to simulate an environment where it is not installed.
Test::Without::Module->import('CHI');
# Verify the block is effective for new require calls.
eval { require CHI };
ok($@, 'optional-chi: CHI cannot be required when blocked by Test::Without::Module');
diag "[optional-chi] require CHI error: $@" if $ENV{TEST_VERBOSE} && $@;
# CSC itself never calls require CHI â it only interacts with whatever object
# the caller passes as cache =>. A hash ref works with no CHI in the process.
my $obj = Class::Simple::Cached->new(cache => {});
$obj->field('present');
is($obj->field(), 'present',
'optional-chi: hash-ref backend operates correctly without CHI');
( run in 2.728 seconds using v1.01-cache-2.11-cpan-800906f7e73 )