summary refs log tree commit diff
path: root/t/spore-middleware/useragent.t
blob: 190a66ef49989dc287d79731031f0ba00ba178db (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
use strict;
use warnings;

use Test::More;
use Net::HTTP::Spore;

my $mock_server = {
    '/show' => sub {
        my $req = shift;
        $req->new_response( 200, [ 'Content-Type' => 'text/plain' ], 'ok');
    },
};

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

my $ua_str = 'Test::Spore middleware';

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

my $res = $client->get_info();
is $res->request->header('User-Agent'), $ua_str;

done_testing;