mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Merge pull request #99229 from tanjing2020/subtests
attacher: organize unit tests into subtests
This commit is contained in:
commit
4cc1127e92
@ -62,7 +62,7 @@ func TestGetVolumeName_PersistentVolume(t *testing.T) {
|
|||||||
|
|
||||||
// One testcase for TestAttachDetach table test below
|
// One testcase for TestAttachDetach table test below
|
||||||
type testcase struct {
|
type testcase struct {
|
||||||
name aws.KubernetesVolumeID
|
name string
|
||||||
// For fake AWS:
|
// For fake AWS:
|
||||||
attach attachCall
|
attach attachCall
|
||||||
detach detachCall
|
detach detachCall
|
||||||
@ -128,15 +128,16 @@ func TestAttachDetach(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testcase := range tests {
|
for _, testcase := range tests {
|
||||||
testcase.t = t
|
t.Run(testcase.name, func(t *testing.T) {
|
||||||
device, err := testcase.test(&testcase)
|
testcase.t = t
|
||||||
if err != testcase.expectedError {
|
device, err := testcase.test(&testcase)
|
||||||
t.Errorf("%s failed: expected err=%q, got %q", testcase.name, testcase.expectedError.Error(), err.Error())
|
if err != testcase.expectedError {
|
||||||
}
|
t.Errorf("failed: expected err=%q, got %q", testcase.expectedError.Error(), err.Error())
|
||||||
if device != testcase.expectedDevice {
|
}
|
||||||
t.Errorf("%s failed: expected device=%q, got %q", testcase.name, testcase.expectedDevice, device)
|
if device != testcase.expectedDevice {
|
||||||
}
|
t.Errorf("failed: expected device=%q, got %q", testcase.expectedDevice, device)
|
||||||
t.Logf("Test %q succeeded", testcase.name)
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user