| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | use Test::More; |
| 7 | |
| 8 | BEGIN { |
| 9 | plan skip_all => "This test requires File::Temp" unless eval { require File::Temp }; |
| 10 | plan tests => 4; |
| 11 | } |
| 12 | |
| 13 | use Test::Exception; |
| 14 | |
| 15 | use ok "Catalyst::Plugin::Cache::Backend::FastMmap"; |
| 16 | |
| 17 | my ( $fh, $name ) = File::Temp::tempfile(); |
| 18 | |
| 19 | my $cache = Catalyst::Plugin::Cache::Backend::FastMmap->new( |
| 20 | share_file => $name, |
| 21 | ); |
| 22 | |
| 23 | lives_ok { |
| 24 | $cache->set( key => "non_ref" ); |
| 25 | } "you can set non references too"; |
| 26 | |
| 27 | is( $cache->get("key"), "non_ref", "they are returned properly" ); |
| 28 | |
| 29 | $cache->set( complex => my $d = { foo => [qw/bar gorch/], baz => "moose" } ); |
| 30 | |
| 31 | is_deeply( $cache->get("complex"), $d, "storing of refs is unaffected" ); |
| 32 | |
| 33 | END { |
| 34 | close $fh; |
| 35 | unlink $name if -e $name; |
| 36 | } |