Skip to content

Commit

Permalink
pkg/names: test namespaced external metrics selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfantom committed May 17, 2019
1 parent 4863247 commit c58c32e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/naming/metrics_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,19 @@ func TestBuildExternalSelector(t *testing.T) {
hasSelector("[foo bar]"),
),
},
{
name: "multiple GroupBySlice values with namespace",

mq: mustNewQuery(`<<index .LabelValuesByName "namespaces">> <<.GroupBySlice>>`, false),
namespace: "default",
groupBySlice: []string{"foo", "bar"},
metricSelector: labels.NewSelector(),

check: checks(
hasError(nil),
hasSelector("default [foo bar]"),
),
},
{
name: "single LabelMatchers value",

Expand All @@ -313,6 +326,20 @@ func TestBuildExternalSelector(t *testing.T) {
hasSelector(`foo="bar"`),
),
},
{
name: "single LabelMatchers value with namespace",

mq: mustNewQuery(`<<.LabelMatchers>>`, false),
namespace: "default",
metricSelector: labels.NewSelector().Add(
*mustNewLabelRequirement("foo", selection.Equals, []string{"bar"}),
),

check: checks(
hasError(nil),
hasSelector(`foo="bar",namespaces="default"`),
),
},
{
name: "multiple LabelMatchers value",

Expand Down Expand Up @@ -353,6 +380,20 @@ func TestBuildExternalSelector(t *testing.T) {
hasSelector("map[foo:bar|baz]"),
),
},
{
name: "single LabelValuesByName with multiple selectors and namespace",

mq: mustNewQuery(`<<.LabelValuesByName>>`, false),
namespace: "default",
metricSelector: labels.NewSelector().Add(
*mustNewLabelRequirement("foo", selection.In, []string{"bar", "baz"}),
),

check: checks(
hasError(nil),
hasSelector("map[foo:bar|baz namespaces:default]"),
),
},
}

for _, tc := range tests {
Expand Down

0 comments on commit c58c32e

Please sign in to comment.