-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path005a_basic_w_cache_store.t
More file actions
76 lines (60 loc) · 1.71 KB
/
005a_basic_w_cache_store.t
File metadata and controls
76 lines (60 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Plack::Request;
use Plack::Session::State;
use Plack::Session::Store::Cache;
use t::lib::TestSessionHash;
{
package TestCache;
sub new {
bless {} => shift;
}
sub set {
my ($self, $key, $val ) = @_;
$self->{$key} = $val;
}
sub get {
my ($self, $key ) = @_;
$self->{$key};
}
sub remove {
my ($self, $key ) = @_;
delete $self->{$key};
}
}
t::lib::TestSessionHash::run_all_tests(
store => Plack::Session::Store::Cache->new( cache => TestCache->new ),
state => Plack::Session::State->new,
env_cb => sub {
open my $in, '<', \do { my $d };
my $env = {
'psgi.version' => [ 1, 0 ],
'psgi.input' => $in,
'psgi.errors' => *STDERR,
'psgi.url_scheme' => 'http',
SERVER_PORT => 80,
REQUEST_METHOD => 'GET',
QUERY_STRING => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
};
},
);
my $cache = TestCache->new;
t::lib::TestSessionHash::run_all_tests(
store => Plack::Session::Store::Cache->new( get_cache => sub { $cache } ),
state => Plack::Session::State->new,
env_cb => sub {
open my $in, '<', \do { my $d };
my $env = {
'psgi.version' => [ 1, 0 ],
'psgi.input' => $in,
'psgi.errors' => *STDERR,
'psgi.url_scheme' => 'http',
SERVER_PORT => 80,
REQUEST_METHOD => 'GET',
QUERY_STRING => join "&" => map { $_ . "=" . $_[0]->{ $_ } } keys %{$_[0] || +{}},
};
},
);
done_testing;