File: check_names_test.cc

package info (click to toggle)
prometheus-cpp 1.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 792 kB
  • sloc: cpp: 3,596; sh: 37; makefile: 12
file content (34 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (3)
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
#include "prometheus/check_names.h"

#include <gtest/gtest.h>

namespace prometheus {
namespace {

TEST(CheckNamesTest, empty_metric_name) { EXPECT_FALSE(CheckMetricName("")); }
TEST(CheckNamesTest, good_metric_name) {
  EXPECT_TRUE(CheckMetricName("prometheus_notifications_total"));
}
TEST(CheckNamesTest, reserved_metric_name) {
  EXPECT_FALSE(CheckMetricName("__some_reserved_metric"));
}
TEST(CheckNamesTest, malformed_metric_name) {
  EXPECT_FALSE(CheckMetricName("fa mi ly with space in name or |"));
}
TEST(CheckNamesTest, empty_label_name) { EXPECT_FALSE(CheckLabelName("")); }
TEST(CheckNamesTest, invalid_label_name) {
  EXPECT_FALSE(CheckLabelName("log-level"));
}
TEST(CheckNamesTest, leading_invalid_label_name) {
  EXPECT_FALSE(CheckLabelName("-abcd"));
}
TEST(CheckNamesTest, trailing_invalid_label_name) {
  EXPECT_FALSE(CheckLabelName("abcd-"));
}
TEST(CheckNamesTest, good_label_name) { EXPECT_TRUE(CheckLabelName("type")); }
TEST(CheckNamesTest, reserved_label_name) {
  EXPECT_FALSE(CheckMetricName("__some_reserved_label"));
}

}  // namespace
}  // namespace prometheus