make temporary directory by myself
[catagits/Web-Session.git] / t / 004_basic_file_w_customs.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use File::Spec;
6
7 use Test::More;
8
9 BEGIN {
10     eval "use YAML";
11     plan skip_all => "This test requires YAML" if $@;
12 }
13
14 use Plack::Request;
15 use Plack::Session;
16 use Plack::Session::State::Cookie;
17 use Plack::Session::Store::File;
18
19 use t::lib::TestSession;
20
21 my $TMP = File::Spec->catdir('t', 'tmp');
22 if ( !-d $TMP ) {
23     mkdir $TMP;
24 }
25
26 t::lib::TestSession::run_all_tests(
27     store           => Plack::Session::Store::File->new(
28         dir          => $TMP,
29         serializer   => sub { YAML::DumpFile( reverse @_ ) }, # YAML takes it's args the opposite of Storable
30         deserializer => sub { YAML::LoadFile( @_ ) },
31     ),
32     state           => Plack::Session::State->new,
33     request_creator => sub {
34         open my $in, '<', \do { my $d };
35         my $env = {
36             'psgi.version'    => [ 1, 0 ],
37             'psgi.input'      => $in,
38             'psgi.errors'     => *STDERR,
39             'psgi.url_scheme' => 'http',
40             SERVER_PORT       => 80,
41             REQUEST_METHOD    => 'GET',
42         };
43         my $r = Plack::Request->new( $env );
44         $r->parameters( @_ );
45         $r;
46     },
47 );
48
49 unlink $_ foreach glob( File::Spec->catdir($TMP, '*') );
50
51 done_testing;