File: 21-clear.t

package info (click to toggle)
libprometheus-tiny-perl 0.011-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 180 kB
  • sloc: perl: 746; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,028 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
41
42
43
44
#!perl

use warnings;
use strict;

use Test::More;

use Prometheus::Tiny;

my $p = Prometheus::Tiny->new;
$p->declare('some_metric', help => 'My great metric', type => 'counter');
$p->declare('other_metric', help => 'My other great metric', type => 'gauge');

$p->set('some_metric', 5);
$p->set('other_metric', 10);
is $p->format, <<EOF, 'normal operation';
# HELP other_metric My other great metric
# TYPE other_metric gauge
other_metric 10
# HELP some_metric My great metric
# TYPE some_metric counter
some_metric 5
EOF

$p->clear;
is $p->format, <<EOF, 'no metrics after clearing, just the meta';
# HELP other_metric My other great metric
# TYPE other_metric gauge
# HELP some_metric My great metric
# TYPE some_metric counter
EOF

$p->set('some_metric', 20);
$p->set('other_metric', 30);
is $p->format, <<EOF, 'new metrics values after clear';
# HELP other_metric My other great metric
# TYPE other_metric gauge
other_metric 30
# HELP some_metric My great metric
# TYPE some_metric counter
some_metric 20
EOF

done_testing;