mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
* initial commit * variable substitution * update tests * update test * refactor engine packages for validate & generate * update vendor * update toml * support variable substitution in overlay mutation * missing update * fix indentation in logs * store context values as single JSON document using merge patches. * remove duplicate functions * fix message string * Handle processing of policies in background (#569) * remove condition check while generating mutation patch as conditions are verified in the first iteration * initial commit * background policy validation * correct message * skip non-background policy process for add/update * fix order to correct policy registration * update comment Co-authored-by: shuting <shutting06@gmail.com> * refactor Co-authored-by: shuting <shutting06@gmail.com>
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package anchor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
func TestWrappedWithParentheses_StringIsWrappedWithParentheses(t *testing.T) {
|
|
str := "(something)"
|
|
assert.Assert(t, IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestWrappedWithParentheses_StringHasOnlyParentheses(t *testing.T) {
|
|
str := "()"
|
|
assert.Assert(t, IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestWrappedWithParentheses_StringHasNoParentheses(t *testing.T) {
|
|
str := "something"
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestWrappedWithParentheses_StringHasLeftParentheses(t *testing.T) {
|
|
str := "(something"
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestWrappedWithParentheses_StringHasRightParentheses(t *testing.T) {
|
|
str := "something)"
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestWrappedWithParentheses_StringParenthesesInside(t *testing.T) {
|
|
str := "so)m(et(hin)g"
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestWrappedWithParentheses_Empty(t *testing.T) {
|
|
str := ""
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
}
|
|
|
|
func TestIsExistanceAnchor_Yes(t *testing.T) {
|
|
assert.Assert(t, IsExistanceAnchor("^(abc)"))
|
|
}
|
|
|
|
func TestIsExistanceAnchor_NoRightBracket(t *testing.T) {
|
|
assert.Assert(t, !IsExistanceAnchor("^(abc"))
|
|
}
|
|
|
|
func TestIsExistanceAnchor_OnlyHat(t *testing.T) {
|
|
assert.Assert(t, !IsExistanceAnchor("^abc"))
|
|
}
|
|
|
|
func TestIsExistanceAnchor_ConditionAnchor(t *testing.T) {
|
|
assert.Assert(t, !IsExistanceAnchor("(abc)"))
|
|
}
|