summary refs log tree commit diff
path: root/t/spore-request/form_data.t
blob: 640046511b15d94af7bbf17189e24eaa52d53a56 (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
use strict;
use warnings;
use Test::More;

use Net::HTTP::Spore;

my $mock_server = {
    '/email' => sub {
        my $req   = shift;
        my $final = $req->finalize;
        like $final->header('Content-Type'),
          qr/multipart\/form-data; boundary=/;
        $req->new_response( 200, [ 'Content-Type' => 'text/html' ], 'ok' );
    },
};

ok my $client =
  Net::HTTP::Spore->new_from_spec( 't/specs/api.json',
    base_url => 'http://localhost' );

$client->enable( 'Mock', tests => $mock_server );

my $res = $client->add_email( email => 'foo@bar.com' );
is $res->[0],   200;
like $res->[2], qr/ok/;

done_testing;