blob: b9d7e1f973ae2611bcae13bbe1febe948296c970 (
plain) (
blame)
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
|
use Test::More tests => 4;
use strict;
use warnings;
#ok 1;
use jitterbug;
use JSON;
use YAML qw/LoadFile/;
use Dancer::Test;
use Dancer::Config qw/setting/;
my $content = LoadFile('t/data/test.yaml');
setting jitterbug => { namespace => 'jitterbug_test' };
route_exists [ POST => '/hook/' ], 'a route handle is defined for /';
my $response;
{
$response = dancer_response( POST => '/hook', );
is $response->{status}, 200, '200 with empty post';
}
{
my $payload = "payload=" . JSON::encode_json($content);
#open my $in, '<', \$payload;
#$ENV{'CONTENT_LENGTH'} = length($payload);
#$ENV{'CONTENT_TYPE'} = 'application/x-www-form-urlencoded';
#$ENV{'psgi.input'} = $in;
$response = dancer_response(
POST => '/hook/',
{
headers =>
[ 'Content-Type' => 'application/x-www-form-urlencoded' ],
body => $payload
}
);
#use YAML::Syck; warn Dump $response;
is $response->{status}, 200;
is_deeply JSON::decode_json( $response->{content} ),
{ updated => 'Dancer' };
}
|