This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update HTTP-Tiny to CPAN version 0.033
[perl5.git] / cpan / HTTP-Tiny / t / 003_agent.t
CommitLineData
d72a6fbd
CBW
1#!perl
2
3use strict;
4use warnings;
5
9a00675d 6use Test::More tests => 8;
d72a6fbd
CBW
7use HTTP::Tiny;
8
9# a couple tests to ensure that we get the default agent expected, the coorect
10# agent when specified, and the correct agent when specifified with a space at
11# the end of the string (as LWP::UserAgent does)
12
13
14my $default = 'HTTP-Tiny/' . (HTTP::Tiny->VERSION || 0);
15
16{
17 my $ua = HTTP::Tiny->new();
18 is $ua->agent, $default, 'default agent string is as expected';
19}
20
21{
22 my $ua = HTTP::Tiny->new(agent => 'something else');
23 is $ua->agent, 'something else', 'agent string is as expected';
24}
25
26{
27 my $ua = HTTP::Tiny->new(agent => 'something else ');
28 is
29 $ua->agent,
30 "something else $default",
31 'agent string is as properly appended to',
32 ;
33}
9a00675d
CBW
34
35{
36 my $ua = HTTP::Tiny->new();
37
38 is( HTTP::Tiny->_agent(), $default, 'check _agent on class' );
39 is $ua->_agent(), $default, 'check _agent on object';
40
41 $ua->agent(undef);
42 is $ua->agent, undef, 'agent string is empty';
43
44 $ua->agent('something else');
45 is $ua->agent, 'something else', 'agent string is as expected';
46
47 $ua->agent('something else ');
48 is
49 $ua->agent,
50 "something else $default",
51 'agent string is as properly appended to',
52 ;
53}