From 42264122b67b43c27cd5a78641d78db1ec5a0c9c Mon Sep 17 00:00:00 2001 From: yhgjt <1026228725@qq.com> Date: Fri, 7 Mar 2025 04:56:27 -0800 Subject: [PATCH 1/2] add notation to dotestcases inpkg\ddc\juicefs\delete_volume_test.go Signed-off-by: yhgjt <1026228725@qq.com> --- pkg/ddc/juicefs/delete_volume_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/ddc/juicefs/delete_volume_test.go b/pkg/ddc/juicefs/delete_volume_test.go index 1a9527ede0d..6baf6417f09 100644 --- a/pkg/ddc/juicefs/delete_volume_test.go +++ b/pkg/ddc/juicefs/delete_volume_test.go @@ -56,7 +56,12 @@ func newTestJuiceEngine(client client.Client, name string, namespace string, wit } return engine } - +// doTestCases 是一个测试函数,用于验证删除 PersistentVolume (PV) 的行为是否符合预期。 +// 该函数接收一个 TestCase 切片和一个 testing.T 对象作为参数,遍历每个测试用例并执行以下操作: +// 1. 调用测试用例中的 engine 的 DeleteVolume 方法,尝试删除 PV。 +// 2. 获取删除后的 PV 对象,并与一个空的 PV 对象进行比较,判断 PV 是否被成功删除。 +// 3. 检查 DeleteVolume 方法的返回值,验证是否与测试用例中预期的错误状态一致。 +// 如果 PV 删除状态或错误状态与预期不符,函数会通过 testing.T 的 Errorf 方法报告错误。 func doTestCases(testCases []TestCase, t *testing.T) { for _, test := range testCases { err := test.engine.DeleteVolume() From 1e2dbd6266760e91db9492152e3b8f555f206975 Mon Sep 17 00:00:00 2001 From: yhgjt <1026228725@qq.com> Date: Fri, 7 Mar 2025 21:14:42 -0800 Subject: [PATCH 2/2] add notation to doTestCases in pkg/ddc/juicefs/delete_volume_test.go Signed-off-by: yhgjt <1026228725@qq.com> --- pkg/ddc/juicefs/delete_volume_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/ddc/juicefs/delete_volume_test.go b/pkg/ddc/juicefs/delete_volume_test.go index 6baf6417f09..a7959497324 100644 --- a/pkg/ddc/juicefs/delete_volume_test.go +++ b/pkg/ddc/juicefs/delete_volume_test.go @@ -56,12 +56,13 @@ func newTestJuiceEngine(client client.Client, name string, namespace string, wit } return engine } -// doTestCases 是一个测试函数,用于验证删除 PersistentVolume (PV) 的行为是否符合预期。 -// 该函数接收一个 TestCase 切片和一个 testing.T 对象作为参数,遍历每个测试用例并执行以下操作: -// 1. 调用测试用例中的 engine 的 DeleteVolume 方法,尝试删除 PV。 -// 2. 获取删除后的 PV 对象,并与一个空的 PV 对象进行比较,判断 PV 是否被成功删除。 -// 3. 检查 DeleteVolume 方法的返回值,验证是否与测试用例中预期的错误状态一致。 -// 如果 PV 删除状态或错误状态与预期不符,函数会通过 testing.T 的 Errorf 方法报告错误。 + +// doTestCases is a test function used to verify whether the behavior of deleting PersistentVolume (PV) meets expectations. +// The function takes a slice of TestCase and a testing.T object as parameters, iterates through each test case, and performs the following operations: +// 1. Calls the DeleteVolume method of the engine in the test case to attempt to delete the PV. +// 2. Retrieves the PV object after deletion and compares it with an empty PV object to determine if the PV has been successfully deleted. +// 3. Checks the return value of the DeleteVolume method to verify if it matches the expected error state in the test case. +// If the PV deletion status or error state does not match the expected result, the function reports an error using the Errorf method of testing.T. func doTestCases(testCases []TestCase, t *testing.T) { for _, test := range testCases { err := test.engine.DeleteVolume()