File: bloggery.t

package info (click to toggle)
libweb-simple-perl 0.033-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: perl: 1,622; makefile: 7
file content (42 lines) | stat: -rw-r--r-- 956 bytes parent folder | download | duplicates (5)
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
use strict;
use warnings FATAL => 'all';

use Test::More qw(no_plan);

require_ok 'examples/bloggery/bloggery.cgi';

__END__
#use Test::More (
#  eval { require HTTP::Request::AsCGI }
#    ? 'no_plan'
##    : (skip_all => 'No HTTP::Request::AsCGI')
#);
use HTTP::Request::AsCGI;  

use HTTP::Request::Common qw(GET POST);

require 'examples/bloggery/bloggery.cgi';

my $app = Bloggery->new(
  { config => { posts_dir => 'examples/bloggery/posts' } }
);

sub run_request {
  my $request = shift;
  my $c = HTTP::Request::AsCGI->new($request, SCRIPT_NAME=> $0)->setup;
  $app->run;
  $c->restore;
  return $c->response;
}

my $res;

warn run_request(GET 'http://localhost/index.html')->as_string;

warn run_request(GET 'http://localhost/')->as_string;

warn run_request(GET 'http://localhost/One-Post.html')->as_string;

warn run_request(GET 'http://localhost/Not-There.html')->as_string;

warn run_request(POST 'http://localhost/One-Post.html')->as_string;