-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathstats_prometheus_test.go
More file actions
32 lines (26 loc) · 973 Bytes
/
stats_prometheus_test.go
File metadata and controls
32 lines (26 loc) · 973 Bytes
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
// SPDX-License-Identifier: MIT OR Apache-2.0
package main
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/falcosecurity/falcosidekick/types"
)
func TestFalcoNewCounterVec(t *testing.T) {
c := &types.Configuration{
Customfields: make(map[string]string),
}
c.Customfields["test"] = "foo"
c.Customfields["should*fail"] = "bar"
c.Customfields["k8s.cluster.name"] = "my-cluster"
cv := getFalcoNewCounterVec(c)
shouldbe := []string{"hostname", "rule", "priority", "priority_raw", "source", "k8s_ns_name", "k8s_pod_name", "k8s_cluster_name", "test"}
mm, err := cv.GetMetricWithLabelValues(shouldbe...)
if err != nil {
t.Errorf("Error getting Metrics from promauto")
}
metricDescString := mm.Desc().String()
require.Contains(t, metricDescString, "k8s_cluster_name")
require.Contains(t, metricDescString, "test")
require.NotContains(t, metricDescString, "should*fail")
require.NotContains(t, metricDescString, "k8s.cluster.name")
}