@@ -85,33 +85,41 @@ sub is_or_like($$;$) {
85
85
} GET " /virt?foo=bar" ;
86
86
87
87
undef *test_action; # To free $site ref
88
+ }
88
89
89
- sub test_psgi (&@) {
90
- my ($subref , $request , %params ) = @_ ;
91
-
92
- my $path = $request -> uri-> path;
93
-
94
- $site -> mount_psgi($path => sub {$subref -> (@_ ); [200, [], " OK" ]});
90
+ {
91
+ # mount_psgi and PATH_INFO test.
92
+ my $t = sub {
93
+ my ($mount_path , $req_path , $want_pathinfo , $more_desc ) = @_ ;
94
+
95
+ $site -> mount_psgi(
96
+ $mount_path ,
97
+ sub {
98
+ my ($env ) = @_ ;
99
+ is $env -> {PATH_INFO }, $want_pathinfo
100
+ , " mount psgi $mount_path , GET $req_path => PT($want_pathinfo )"
101
+ . ($more_desc // ' ' )
102
+ ;
103
+ [200, [], " OK" ]
104
+ }
105
+ );
106
+
107
+ Plack::Test-> create($app )-> request(GET $req_path )
108
+ };
95
109
96
- $client -> request( $request , %params );
97
- }
110
+ $t -> ( " /mnt " => " /mnt " => " "
111
+ , " : PT maybe '' for root " );
98
112
99
- test_psgi {
100
- (my Env $env ) = @_ ;
101
- is $env -> {PATH_INFO }, " /mpsgi" , " mount psgi path_info" ;
102
- } GET " /mpsgi" ;
113
+ $t -> (" /mnt" => " /mnt/" => " /"
114
+ , " : Nonempty PT must start with /" );
103
115
104
- test_psgi {
105
- (my Env $env ) = @_ ;
106
- is $env -> {PATH_INFO }, " /mpsgi2" , " mount psgi path_info, 2" ;
107
- } GET " /mpsgi2" ;
116
+ $t -> (" /mnt/" => " /mnt/" => " /"
117
+ , " : Last / in mount path is not trimmed from PT" );
108
118
109
- test_psgi {
110
- (my Env $env ) = @_ ;
111
- is $env -> {PATH_INFO }, " /mpsgi" , " mount psgi path_info, overwritten" ;
112
- } GET " /mpsgi" ;
119
+ $t -> (" /mnt2" => " /mnt2" => " "
120
+ , " : mnt2, not mnt. Longest must win." );
121
+ }
113
122
114
- undef *test_psgi; # To free $site ref.
115
123
}
116
124
117
125
my $hello = sub {
0 commit comments