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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
use strict;
use Test::More tests => 7;
use_ok 'Mojo::RabbitMQ::Client';
subtest 'attributes' => sub {
plan tests => 7;
my $c = new_ok(
'Mojo::RabbitMQ::Client',
[
tls => 0,
user => 'guest',
host => 'remote',
port => 16526,
vhost => '/some/'
]
);
is($c->user, 'guest', 'user is guest');
is($c->pass, undef, 'no password');
is($c->host, 'remote', 'host is remote');
is($c->port, 16526, 'port is ok');
is($c->vhost, '/some/', 'proper vhost name');
isa_ok($c->params, 'Mojo::Parameters');
};
subtest 'query param aliases' => sub {
plan tests => 6;
my $a = new_ok(
'Mojo::RabbitMQ::Client',
[
url => 'amqp:///?cacertfile=cacert&certfile=cert&keyfile=key'
. '&fail_if_no_peer_cert=1&connection_timeout=100'
]
);
is($a->param('ca'), 'cacert', 'cacertfile aliased to ca');
is($a->param('cert'), 'cert', 'cerfile aliased to cert');
is($a->param('key'), 'key', 'keyfile aliased to key');
is($a->param('verify'), '1', 'fail_if_no_peer_cert aliased to verify');
is($a->param('timeout'), '100', 'connection_timeout aliased to timeout');
};
subtest 'query param aliases less significant' => sub {
plan tests => 2;
my $a = new_ok('Mojo::RabbitMQ::Client',
[url => 'amqp:///?cacertfile=cacert&ca=ca']);
is($a->param('ca'), 'cacert', 'should take base value, not alias');
};
subtest 'attributes from query params' => sub {
plan tests => 5;
my $a = new_ok('Mojo::RabbitMQ::Client',
[url => 'amqp://?heartbeat=180&timeout=90&channel_max=1']);
is($a->host, 'localhost', 'need this to parse url!');
is($a->heartbeat_timeout, 180, 'heartbeat timeout set');
is($a->connect_timeout, 90, 'connect timeout set');
is($a->max_channels, 1, 'max channels set');
};
subtest 'change default port for amqps scheme' => sub {
plan tests => 6;
my $c = new_ok('Mojo::RabbitMQ::Client', [url => 'amqps://']);
is($c->user, undef, 'no user');
is($c->pass, undef, 'no password');
is($c->host, 'localhost', 'default host');
is($c->port, 5671, 'changed port');
is($c->vhost, '/', 'default vhost');
};
subtest 'keep specified port for amqps scheme' => sub {
plan tests => 6;
my $c = new_ok('Mojo::RabbitMQ::Client', [url => 'amqps://:15673']);
is($c->user, undef, 'no user');
is($c->pass, undef, 'no password');
is($c->host, 'localhost', 'default host');
is($c->port, 15673, 'changed port');
is($c->vhost, '/', 'default vhost');
};
|