File: 120_selected_target.t

package info (click to toggle)
libyahc-perl 0.035-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 440 kB
  • sloc: perl: 3,661; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use YAHC qw/yahc_conn_target/;

my ($yahc, $yahc_storage) = YAHC->new({ host => [ '127.0.0.1', '127.0.0.2' ] });
my $conn = $yahc->request({ path => '/', _test => 1 });

YAHC::_get_next_target($conn);
ok(yahc_conn_target($conn) eq '127.0.0.1', 'target is 127.0.0.1');
YAHC::_get_next_target($conn);
ok(yahc_conn_target($conn) eq '127.0.0.2', 'target is 127.0.0.2');

$conn = $yahc->request({ host => '127.0.0.3', path => '/', _test => 1 });

YAHC::_get_next_target($conn);
ok(yahc_conn_target($conn) eq '127.0.0.3', 'target is 127.0.0.3');

($yahc, $yahc_storage) = YAHC->new({ host => sub { '127.0.0.4' } });
$conn = $yahc->request({ path => '/', _test => 1 });

YAHC::_get_next_target($conn);
ok(yahc_conn_target($conn) eq '127.0.0.4', 'target is 127.0.0.4');

done_testing;