1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 23:46:56 +00:00
kyverno/pkg/engine/context/resolvers/utils_test.go
Charles-Edouard Brétéché 9dd618c13b
chore: move cache enabled label (#7949)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-08-01 16:28:38 +00:00

59 lines
1.2 KiB
Go

package resolvers
import (
"reflect"
"testing"
"time"
"github.com/kyverno/kyverno/api/kyverno"
"k8s.io/client-go/kubernetes"
)
func TestGetCacheSelector(t *testing.T) {
tests := []struct {
name string
want string
wantErr bool
}{{
name: "ok",
want: kyverno.LabelCacheEnabled,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetCacheSelector()
if (err != nil) != tt.wantErr {
t.Errorf("GetCacheSelector() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got.String(), tt.want) {
t.Errorf("GetCacheSelector() = %v, want %v", got, tt.want)
}
})
}
}
func TestGetCacheInformerFactory(t *testing.T) {
tests := []struct {
name string
want string
client kubernetes.Interface
wantErr bool
}{{
name: "nil client",
wantErr: true,
client: nil,
}, {
name: "ok",
wantErr: false,
client: newEmptyFakeClient(),
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := GetCacheInformerFactory(tt.client, 10*time.Minute)
if (err != nil) != tt.wantErr {
t.Errorf("GetCacheInformerFactor() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}