mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 09:47:54 +00:00
Merge pull request #158 from linux-on-ibm-z/cross-compile
Edited Makefile to add cross build support for s390x. Adding External Metrics Provider
This commit is contained in:
commit
c2e176bb23
17 changed files with 1913 additions and 1 deletions
49
pkg/external-provider/regex_matcher_test.go
Normal file
49
pkg/external-provider/regex_matcher_test.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package provider
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/directxman12/k8s-prometheus-adapter/pkg/config"
|
||||
)
|
||||
|
||||
func TestReMatcherIs(t *testing.T) {
|
||||
filter := config.RegexFilter{
|
||||
Is: "my_.*",
|
||||
}
|
||||
|
||||
matcher, err := newReMatcher(filter)
|
||||
require.NoError(t, err)
|
||||
|
||||
result := matcher.Matches("my_label")
|
||||
require.True(t, result)
|
||||
|
||||
result = matcher.Matches("your_label")
|
||||
require.False(t, result)
|
||||
}
|
||||
|
||||
func TestReMatcherIsNot(t *testing.T) {
|
||||
filter := config.RegexFilter{
|
||||
IsNot: "my_.*",
|
||||
}
|
||||
|
||||
matcher, err := newReMatcher(filter)
|
||||
require.NoError(t, err)
|
||||
|
||||
result := matcher.Matches("my_label")
|
||||
require.False(t, result)
|
||||
|
||||
result = matcher.Matches("your_label")
|
||||
require.True(t, result)
|
||||
}
|
||||
|
||||
func TestEnforcesIsOrIsNotButNotBoth(t *testing.T) {
|
||||
filter := config.RegexFilter{
|
||||
Is: "my_.*",
|
||||
IsNot: "your_.*",
|
||||
}
|
||||
|
||||
_, err := newReMatcher(filter)
|
||||
require.Error(t, err)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue