mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-17 23:15:48 +02:00
make controllerinformer interface private;
use named regexp groups
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"regexp"
|
||||
|
||||
"github.com/zalando-incubator/postgres-operator/pkg/spec"
|
||||
)
|
||||
|
||||
@@ -44,6 +46,17 @@ var substractTest = []struct {
|
||||
{[]string{"a", "b", "c", "d"}, []string{"a", "bb", "c", "d"}, []string{"b"}, false},
|
||||
}
|
||||
|
||||
var substringMatch = []struct {
|
||||
inRegex *regexp.Regexp
|
||||
inStr string
|
||||
out map[string]string
|
||||
}{
|
||||
{regexp.MustCompile(`aaaa (?P<num>\d+) bbbb`), "aaaa 123 bbbb", map[string]string{"num": "123"}},
|
||||
{regexp.MustCompile(`aaaa (?P<num>\d+) bbbb`), "a aa 123 bbbb", nil},
|
||||
{regexp.MustCompile(`aaaa \d+ bbbb`), "aaaa 123 bbbb", nil},
|
||||
{regexp.MustCompile(`aaaa (\d+) bbbb`), "aaaa 123 bbbb", nil},
|
||||
}
|
||||
|
||||
func TestRandomPassword(t *testing.T) {
|
||||
const pwdLength = 10
|
||||
pwd := RandomPassword(pwdLength)
|
||||
@@ -100,3 +113,12 @@ func TestSubstractSlices(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindNamedStringSubmatch(t *testing.T) {
|
||||
for _, tt := range substringMatch {
|
||||
actualRes := FindNamedStringSubmatch(tt.inRegex, tt.inStr)
|
||||
if !reflect.DeepEqual(actualRes, tt.out) {
|
||||
t.Errorf("FindNamedStringSubmatch expected: %#v, got: %#v", tt.out, actualRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user