from psgi res tests working
[catagits/Catalyst-Runtime.git] / t / lib / TestFromPSGI / Controller / Root.pm
index 7c116a5..f3a0477 100644 (file)
@@ -1,13 +1,56 @@
-package TestMiddleware::Controller::Root;
+package TestFromPSGI::Controller::Root;
 
 use Moose;
 use MooseX::MethodAttributes;
 
 extends 'Catalyst::Controller';
 
-sub default : Path { }
-sub welcome : Path(welcome) {
-  pop->res->body('Welcome to Catalyst');
+sub test_psgi_keys :Local Args(1) {
+  my ($self, $c, $key) = @_;
+  $c->res->body($c->req->env->{$key});
+}
+
+sub from_psgi_array : Local {
+  my ($self, $c) = @_;
+  my $res = sub {
+    my ($env) = @_;
+    return [200, ['Content-Type'=>'text/plain'],
+      [qw/hello world today/]];
+  }->($c->req->env);
+
+  $c->res->from_psgi_response($res);
+}
+
+sub from_psgi_code : Local {
+  my ($self, $c) = @_;
+
+  my $res = sub {
+    my ($env) = @_;
+    return sub {
+      my $responder = shift;
+      return $responder->([200, ['Content-Type'=>'text/plain'],
+        [qw/hello world today2/]]);
+    };
+  }->($c->req->env);
+
+  $c->res->from_psgi_response($res);
+}
+
+sub from_psgi_code_itr : Local {
+  my ($self, $c) = @_;
+  my $res = sub {
+    my ($env) = @_;
+    return sub {
+      my $responder = shift;
+      my $writer = $responder->([200, ['Content-Type'=>'text/plain']]);
+      $writer->write('hello');
+      $writer->write('world');
+      $writer->write('today3');
+      $writer->close;
+    };
+  }->($c->req->env);
+
+  $c->res->from_psgi_response($res);
 }
 
 __PACKAGE__->meta->make_immutable;