1use strict;
2use warnings;
3
4use Dancer2::Session::YAML ();
5use File::Temp ();
6use IO::File ();
7
8use Test::More;
9
10my $tempdir = File::Temp->newdir;
11
12my $engine = Dancer2::Session::YAML->new( session_dir => $tempdir->dirname );
13my $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
28done_testing();
29