diff --git a/pkg/ddc/jindo/delete_volume_test.go b/pkg/ddc/jindo/delete_volume_test.go index 6204b76bf15..6707c730f92 100644 --- a/pkg/ddc/jindo/delete_volume_test.go +++ b/pkg/ddc/jindo/delete_volume_test.go @@ -76,6 +76,33 @@ func doTestCases(testCases []TestCase, t *testing.T) { } } +// TestJindoEngine_DeleteVolume tests the DeleteVolume method of JindoEngine under various scenarios. +// +// Parameters: +// - t *testing.T : Go testing framework context for test assertions and logging +// +// Test Strategy: +// 1. Setup test environment with mocked Kubernetes resources: +// - PVs with 'CreatedBy=fluid' annotation to simulate Fluid-managed persistent volumes +// - PVCs with different configurations (normal vs error cases) +// 2. Create 3 test scenarios using parameterized test pattern: +// Case 1: Normal deletion (JindoEngineCommon) +// - Input: Valid PV/PVC without conflicting annotations +// - Expected: Successful deletion (isDeleted=true, isErr=false) +// Case 2: Protected PVC deletion (JindoEngineErr) +// - Input: PVC with 'CreatedBy=fluid' annotation (protected resource) +// - Expected: Failed deletion (isErr=true) +// Case 3: Missing runtime scenario (JindoEngineNoRunTime) +// - Input: Engine with runtime=false configuration +// - Expected: Failed deletion (isErr=true) +// 3. Verification: Uses doTestCases() helper to validate deletion outcomes against expectations +// +// Test Resources: +// - fake.NewFakeClientWithScheme: Simulates Kubernetes API server with predefined resources +// - testScheme: Runtime scheme for Kubernetes API objects +// - testPVInputs/testPVCInputs: Predefined PersistentVolume and PersistentVolumeClaim configurations +// +// Note: This test focuses on edge cases for PVC/PV cleanup workflow in Fluid orchestration system. func TestJindoEngine_DeleteVolume(t *testing.T) { testPVInputs := []*v1.PersistentVolume{ {