File: 004_basic_psgi.t

package info (click to toggle)
libfcgi-engine-perl 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 3,226; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,364 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Moose;

BEGIN {
    {
        local $@;
        eval "use Plack;";
        plan skip_all => "Plack is required for this test" if $@;
    }
    {
        local $@;
        eval "use IO::String;";
        plan skip_all => "IO::String is required for this test" if $@;
    }
    plan tests => 13;
    use_ok('FCGI::Engine::PSGI');
}

my $app = sub {
    [ 200, [ 'Content-type' => 'text/html' ], [ 'Hello World' ] ];
};

@ARGV = ();

my $e = FCGI::Engine::PSGI->new_with_options( app => $app );
isa_ok($e, 'FCGI::Engine::PSGI');
isa_ok($e, 'FCGI::Engine::Core');
does_ok($e, 'MooseX::Getopt');

ok(!$e->is_listening, '... we are not listening');
is($e->nproc, 1, '... we have the default 1 proc (but we are not using it)');
ok(!$e->has_pidfile, '... we have no pidfile');
ok(!$e->should_detach, '... we shouldnt daemonize');
is($e->manager, 'FCGI::Engine::ProcManager', '... we have the default manager (FCGI::Engine::ProcManager)');

ok(!$e->has_pre_fork_init, '... we dont have any pre-fork-init');

is($e->app, $app, '... and it is our app');

my $var;
eval {
    tie *STDOUT, 'IO::String' => $var;
    $e->run;
    untie( *STDOUT );
};
ok(!$@, '... we ran the handler okay') || warn $@;

is($var, "Status: 200\r\nContent-type: text/html\r\n\r\nHello World", '... got the expect output too');