Organize framework unit tests in subtests

This commit is contained in:
drfish
2021-01-30 12:29:26 +08:00
parent 24f13032b3
commit 0c3d8b9720
8 changed files with 194 additions and 146 deletions

View File

@@ -1295,14 +1295,16 @@ func TestPodEligibleToPreemptOthers(t *testing.T) {
}
for _, test := range tests {
var nodes []*v1.Node
for _, n := range test.nodes {
nodes = append(nodes, st.MakeNode().Name(n).Obj())
}
snapshot := internalcache.NewSnapshot(test.pods, nodes)
if got := PodEligibleToPreemptOthers(test.pod, snapshot.NodeInfos(), test.nominatedNodeStatus); got != test.expected {
t.Errorf("expected %t, got %t for pod: %s", test.expected, got, test.pod.Name)
}
t.Run(test.name, func(t *testing.T) {
var nodes []*v1.Node
for _, n := range test.nodes {
nodes = append(nodes, st.MakeNode().Name(n).Obj())
}
snapshot := internalcache.NewSnapshot(test.pods, nodes)
if got := PodEligibleToPreemptOthers(test.pod, snapshot.NodeInfos(), test.nominatedNodeStatus); got != test.expected {
t.Errorf("expected %t, got %t for pod: %s", test.expected, got, test.pod.Name)
}
})
}
}