apply review comment

Kubernetes-commit: 54fa811dfd8f0fab63eab030a1ffd5464ecbc499
This commit is contained in:
kfess 2026-04-30 13:59:58 +09:00 committed by Kubernetes Publisher
parent 2e7c871944
commit c388805377

View file

@ -491,7 +491,7 @@ func TestDeleteOrEvictWithDryRunServer(t *testing.T) {
var allPods []runtime.Object
var podsToDelete []corev1.Pod
for i := 1; i <= 4; i++ {
for i := 1; i <= 2; i++ {
pod := corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("mypod-%d", i),
@ -499,20 +499,19 @@ func TestDeleteOrEvictWithDryRunServer(t *testing.T) {
},
}
allPods = append(allPods, &pod)
if i <= 2 {
podsToDelete = append(podsToDelete, pod)
}
podsToDelete = append(podsToDelete, pod)
}
k := fake.NewSimpleClientset(allPods...)
// fake clientset will actually delete objects from the in-memory store.
// This reactor intercepts delete requests with DryRun set and returns success without
// removing the object, simulating real API server dry-run behavior.
k.PrependReactor("delete", "pods", func(actions ktest.Action) (bool, runtime.Object, error) {
deleteAction := actions.(ktest.DeleteAction)
if len(deleteAction.GetDeleteOptions().DryRun) > 0 {
return true, nil, nil
for _, v := range deleteAction.GetDeleteOptions().DryRun {
if v == metav1.DryRunAll {
return true, nil, nil
}
}
return false, nil, nil
})