File: 100-shared.t

package info (click to toggle)
libprometheus-tiny-shared-perl 0.027-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 200 kB
  • sloc: perl: 830; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 807 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!perl

use warnings;
use strict;

use Test::More;

use Prometheus::Tiny::Shared;
use File::Temp qw(tmpnam);

my $filename = scalar tmpnam();

my $p1 = Prometheus::Tiny::Shared->new(filename => $filename);
my $p2 = Prometheus::Tiny::Shared->new(filename => $filename);

# set things on the first one
$p1->set('some_metric', 5);
$p1->set('other_metric', 10);

# format on the second
is $p2->format, <<EOF, 'set on client 1, format on client 2';
other_metric 10
some_metric 5
EOF

# set on the second, format on the first
$p2->set('other_metric', 8);
is $p1->format, <<EOF, 'set on client 2, format on client 1';
other_metric 8
some_metric 5
EOF

my $p3 = Prometheus::Tiny::Shared->new(filename => $filename);
is $p3->format, <<EOF, 'format on late client 3';
other_metric 8
some_metric 5
EOF

done_testing;