Skip to content

Commit c776e80

Browse files
committed
using case name instead
1 parent 7d45e12 commit c776e80

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/controller/podgc/gc_controller_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package podgc
1818

1919
import (
2020
"context"
21-
"fmt"
2221
"sync"
2322
"testing"
2423
"time"
@@ -68,12 +67,13 @@ func TestGCTerminated(t *testing.T) {
6867
}
6968

7069
testCases := []struct {
70+
name string
7171
pods []nameToPhase
7272
threshold int
7373
deletedPodNames sets.String
7474
}{
7575
{
76-
// case 1
76+
name: "threshold = 0, disables terminated pod deletion",
7777
pods: []nameToPhase{
7878
{name: "a", phase: v1.PodFailed},
7979
{name: "b", phase: v1.PodSucceeded},
@@ -83,7 +83,7 @@ func TestGCTerminated(t *testing.T) {
8383
deletedPodNames: sets.NewString(),
8484
},
8585
{
86-
// case 2
86+
name: "threshold = 1, delete pod a which is PodFailed and pod b which is PodSucceeded",
8787
pods: []nameToPhase{
8888
{name: "a", phase: v1.PodFailed},
8989
{name: "b", phase: v1.PodSucceeded},
@@ -93,7 +93,7 @@ func TestGCTerminated(t *testing.T) {
9393
deletedPodNames: sets.NewString("a", "b"),
9494
},
9595
{
96-
// case 3
96+
name: "threshold = 1, delete pod b which is PodSucceeded",
9797
pods: []nameToPhase{
9898
{name: "a", phase: v1.PodRunning},
9999
{name: "b", phase: v1.PodSucceeded},
@@ -103,7 +103,7 @@ func TestGCTerminated(t *testing.T) {
103103
deletedPodNames: sets.NewString("b"),
104104
},
105105
{
106-
// case 4
106+
name: "threshold = 1, delete pod a which is PodFailed",
107107
pods: []nameToPhase{
108108
{name: "a", phase: v1.PodFailed},
109109
{name: "b", phase: v1.PodSucceeded},
@@ -112,7 +112,7 @@ func TestGCTerminated(t *testing.T) {
112112
deletedPodNames: sets.NewString("a"),
113113
},
114114
{
115-
// case 5
115+
name: "threshold = 5, don't delete pod",
116116
pods: []nameToPhase{
117117
{name: "a", phase: v1.PodFailed},
118118
{name: "b", phase: v1.PodSucceeded},
@@ -123,7 +123,7 @@ func TestGCTerminated(t *testing.T) {
123123
}
124124

125125
for i, test := range testCases {
126-
t.Run(fmt.Sprintf("case: %v", i), func(t *testing.T) {
126+
t.Run(test.name, func(t *testing.T) {
127127
client := fake.NewSimpleClientset(&v1.NodeList{Items: []v1.Node{*testutil.NewNode("node")}})
128128
gcc, podInformer, _ := NewFromClient(client, test.threshold)
129129
deletedPodNames := make([]string, 0)

0 commit comments

Comments
 (0)