1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/engine/jmespath/functionentry_test.go
Charles-Edouard Brétéché 6d9d3b7f4c
fix: remove jmespath replace directive (#7726)
* fix: remove jmespath replace directive

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* master

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Co-authored-by: shuting <shuting@nirmata.com>
2023-07-07 10:22:26 +00:00

64 lines
1.4 KiB
Go

package jmespath
import (
"testing"
gojmespath "github.com/kyverno/go-jmespath"
)
func TestFunctionEntry_String(t *testing.T) {
type fields struct {
FunctionEntry gojmespath.FunctionEntry
Note string
ReturnType []jpType
}
tests := []struct {
name string
fields fields
want string
}{{
fields: fields{
FunctionEntry: gojmespath.FunctionEntry{
Name: compare,
Arguments: []argSpec{
{Types: []jpType{jpString}},
{Types: []jpType{jpString}},
},
Handler: jpfCompare,
},
ReturnType: []jpType{jpNumber},
Note: "compares two strings lexicographically",
},
want: "compare(string, string) number (compares two strings lexicographically)",
}, {
fields: fields{
Note: "compares two strings lexicographically",
},
want: "",
}, {
fields: fields{
FunctionEntry: gojmespath.FunctionEntry{
Name: compare,
Arguments: []argSpec{
{Types: []jpType{jpString}},
{Types: []jpType{jpString}},
},
Handler: jpfCompare,
},
ReturnType: []jpType{jpNumber},
},
want: "compare(string, string) number",
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := FunctionEntry{
FunctionEntry: tt.fields.FunctionEntry,
Note: tt.fields.Note,
ReturnType: tt.fields.ReturnType,
}
if got := f.String(); got != tt.want {
t.Errorf("FunctionEntry.String() = %v, want %v", got, tt.want)
}
})
}
}