mirror of
https://github.com/kyverno/kyverno.git
synced 2025-01-20 18:52:16 +00:00
Merge pull request #1946 from RinkiyaKeDad/1944_more_than_fix
fix operator matching with spacing
This commit is contained in:
commit
5dfd16ce44
2 changed files with 5 additions and 0 deletions
|
@ -183,6 +183,7 @@ func validateValueWithStringPattern(log logr.Logger, value interface{}, pattern
|
|||
|
||||
operator := operator.GetOperatorFromStringPattern(pattern)
|
||||
pattern = pattern[len(operator):]
|
||||
pattern = strings.TrimSpace(pattern)
|
||||
number, str := getNumberAndStringPartsFromPattern(pattern)
|
||||
|
||||
if "" == number {
|
||||
|
|
|
@ -306,6 +306,10 @@ func TestGetNumberAndStringPartsFromPattern_Empty(t *testing.T) {
|
|||
assert.Equal(t, str, "")
|
||||
}
|
||||
|
||||
func TestValidateValueWithStringPattern_WithSpace(t *testing.T) {
|
||||
assert.Assert(t, validateValueWithStringPattern(log.Log, 4, ">= 3"))
|
||||
}
|
||||
|
||||
func TestValidateNumberWithStr_LessFloatAndInt(t *testing.T) {
|
||||
assert.Assert(t, validateNumberWithStr(log.Log, 7.00001, "7.000001", operator.More))
|
||||
assert.Assert(t, validateNumberWithStr(log.Log, 7.00001, "7", operator.NotEqual))
|
||||
|
|
Loading…
Add table
Reference in a new issue