mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
pv controller test: use sub tests
This makes it possible to run individual tests.
This commit is contained in:
parent
06f934ea1f
commit
22f81e9e0b
@ -632,9 +632,7 @@ func evaluateTestResults(ctrl *PersistentVolumeController, reactor *pvtesting.Vo
|
|||||||
// controllerTest.testCall *once*.
|
// controllerTest.testCall *once*.
|
||||||
// 3. Compare resulting volumes and claims with expected volumes and claims.
|
// 3. Compare resulting volumes and claims with expected volumes and claims.
|
||||||
func runSyncTests(t *testing.T, tests []controllerTest, storageClasses []*storage.StorageClass, pods []*v1.Pod) {
|
func runSyncTests(t *testing.T, tests []controllerTest, storageClasses []*storage.StorageClass, pods []*v1.Pod) {
|
||||||
for _, test := range tests {
|
doit := func(t *testing.T, test controllerTest) {
|
||||||
klog.V(4).Infof("starting test %q", test.name)
|
|
||||||
|
|
||||||
// Initialize the controller
|
// Initialize the controller
|
||||||
client := &fake.Clientset{}
|
client := &fake.Clientset{}
|
||||||
ctrl, err := newTestController(client, nil, true)
|
ctrl, err := newTestController(client, nil, true)
|
||||||
@ -679,6 +677,13 @@ func runSyncTests(t *testing.T, tests []controllerTest, storageClasses []*storag
|
|||||||
|
|
||||||
evaluateTestResults(ctrl, reactor.VolumeReactor, test, t)
|
evaluateTestResults(ctrl, reactor.VolumeReactor, test, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
test := test
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
doit(t, test)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test multiple calls to syncClaim/syncVolume and periodic sync of all
|
// Test multiple calls to syncClaim/syncVolume and periodic sync of all
|
||||||
|
@ -273,9 +273,7 @@ func TestControllerSync(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
doit := func(test controllerTest) {
|
||||||
klog.V(4).Infof("starting test %q", test.name)
|
|
||||||
|
|
||||||
// Initialize the controller
|
// Initialize the controller
|
||||||
client := &fake.Clientset{}
|
client := &fake.Clientset{}
|
||||||
|
|
||||||
@ -353,6 +351,13 @@ func TestControllerSync(t *testing.T) {
|
|||||||
|
|
||||||
evaluateTestResults(ctrl, reactor.VolumeReactor, test, t)
|
evaluateTestResults(ctrl, reactor.VolumeReactor, test, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
test := test
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
doit(test)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func storeVersion(t *testing.T, prefix string, c cache.Store, version string, expectedReturn bool) {
|
func storeVersion(t *testing.T, prefix string, c cache.Store, version string, expectedReturn bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user