]> Sergey Matveev's repositories - public-inbox.git/blob - t/config_limiter.t
No ext_urls
[public-inbox.git] / t / config_limiter.t
1 # Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 use strict;
4 use warnings;
5 use Test::More;
6 use PublicInbox::Config;
7 my $cfgpfx = "publicinbox.test";
8 {
9         my $config = PublicInbox::Config->new(\<<EOF);
10 $cfgpfx.address=test\@example.com
11 $cfgpfx.inboxdir=/path/to/non/existent
12 $cfgpfx.httpbackendmax=12
13 EOF
14         my $ibx = $config->lookup_name('test');
15         my $git = $ibx->git;
16         my $old = "$git";
17         my $lim = $git->{-httpbackend_limiter};
18         ok($lim, 'Limiter exists');
19         is($lim->{max}, 12, 'limiter has expected slots');
20         $ibx->{git} = undef;
21         $git = $ibx->git;
22         isnt($old, "$git", 'got new Git object');
23         is("$git->{-httpbackend_limiter}", "$lim", 'same limiter');
24 }
25
26 {
27         my $config = PublicInbox::Config->new(\<<EOF);
28 publicinboxlimiter.named.max=3
29 $cfgpfx.address=test\@example.com
30 $cfgpfx.inboxdir=/path/to/non/existent
31 $cfgpfx.httpbackendmax=named
32 EOF
33         my $ibx = $config->lookup_name('test');
34         my $git = $ibx->git;
35         ok($git, 'got git object');
36         my $old = "$git"; # stringify object ref "Git(0xDEADBEEF)"
37         my $lim = $git->{-httpbackend_limiter};
38         ok($lim, 'Limiter exists');
39         is($lim->{max}, 3, 'limiter has expected slots');
40         $ibx->{git} = undef;
41         my $new = $ibx->git;
42         isnt($old, "$new", 'got new Git object');
43         is("$new->{-httpbackend_limiter}", "$lim", 'same limiter');
44         is($lim->{max}, 3, 'limiter has expected slots');
45 }
46
47 done_testing;