mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
c9bbf38191
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
46 lines
761 B
Go
46 lines
761 B
Go
package admission
|
|
|
|
import (
|
|
"testing"
|
|
|
|
admissionv1 "k8s.io/api/admission/v1"
|
|
)
|
|
|
|
func TestIsDryRun(t *testing.T) {
|
|
true := true
|
|
false := false
|
|
type args struct {
|
|
request admissionv1.AdmissionRequest
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want bool
|
|
}{{
|
|
args: args{
|
|
request: admissionv1.AdmissionRequest{},
|
|
},
|
|
want: false,
|
|
}, {
|
|
args: args{
|
|
request: admissionv1.AdmissionRequest{
|
|
DryRun: &true,
|
|
},
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
request: admissionv1.AdmissionRequest{
|
|
DryRun: &false,
|
|
},
|
|
},
|
|
want: false,
|
|
}}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := IsDryRun(tt.args.request); got != tt.want {
|
|
t.Errorf("IsDryRun() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|