mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 09:26:54 +00:00
23 lines
544 B
Go
23 lines
544 B
Go
|
package regex
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"gotest.tools/assert"
|
||
|
)
|
||
|
|
||
|
func Test_RegexVariables(t *testing.T) {
|
||
|
vars := RegexVariables.FindAllString("tag: {{ value }}", -1)
|
||
|
assert.Equal(t, len(vars), 1)
|
||
|
assert.Equal(t, vars[0], " {{ value }}")
|
||
|
|
||
|
res := RegexVariables.ReplaceAllString("tag: {{ value }}", "${1}test")
|
||
|
assert.Equal(t, res, "tag: test")
|
||
|
}
|
||
|
|
||
|
func Test_IsVariable(t *testing.T) {
|
||
|
assert.Equal(t, IsVariable("{{ foo }}"), true)
|
||
|
assert.Equal(t, IsVariable("{{ foo {{foo2}} }}"), true)
|
||
|
assert.Equal(t, IsVariable("\\{{ foo }}"), false)
|
||
|
}
|