| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
|
| 4 |
use Dancer2::Session::YAML (); |
| 5 |
use File::Temp (); |
| 6 |
use IO::File (); |
| 7 |
|
| 8 |
use Test::More; |
| 9 |
|
| 10 |
my $tempdir = File::Temp->newdir; |
| 11 |
|
| 12 |
my $engine = Dancer2::Session::YAML->new( session_dir => $tempdir->dirname ); |
| 13 |
my $session_id = do { |
| 14 |
my $session = $engine->create; |
| 15 |
isa_ok $session, 'Dancer2::Core::Session', 'Create a session'; |
| 16 |
ok $session->write( uvw => 7 ), 'Store a session value'; |
| 17 |
ok $session->write( xyz => $tempdir ), 'Store a session object'; |
| 18 |
ok $engine->flush( session => $session ), 'Flush the session store'; |
| 19 |
$session->id; |
| 20 |
}; |
| 21 |
{ |
| 22 |
my $session = $engine->retrieve( id => $session_id ); |
| 23 |
isa_ok $session, 'Dancer2::Core::Session', 'Retrieve the session'; |
| 24 |
is $session->read('uvw'), 7, 'The session has stored the value'; |
| 25 |
isa_ok $session->read('xyz'),'File::Temp::Dir', 'The session has stored the object'; |
| 26 |
} |
| 27 |
|
| 28 |
done_testing(); |