File: 041-enum.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 (32 lines) | stat: -rw-r--r-- 801 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
#!perl

use warnings;
use strict;

use Test::More;

use Prometheus::Tiny::Shared;

{
  my $p = Prometheus::Tiny::Shared->new;
  $p->declare('some_state', enum => 'state', enum_values => [qw(FOO BAR BAZ)]);
  $p->enum_set('some_state', 'FOO');
  is $p->format, <<EOF, 'single enum set formatted correctly';
some_state{state="BAR"} 0
some_state{state="BAZ"} 0
some_state{state="FOO"} 1
EOF
}

{
  my $p = Prometheus::Tiny::Shared->new;
  $p->declare('some_state', enum => 'state', enum_values => [qw(FOO BAR BAZ)]);
  $p->enum_set('some_state', 'BAR', { one => "1", two => "2" });
  is $p->format, <<EOF, 'single enum set with lables formatted correctly';
some_state{one="1",state="BAR",two="2"} 1
some_state{one="1",state="BAZ",two="2"} 0
some_state{one="1",state="FOO",two="2"} 0
EOF
}

done_testing;