@@ -368,6 +368,35 @@ func TestGetDataSetFileNum(t *testing.T) {
368368 }
369369}
370370
371+ // TestGetRuntime tests the AlluxioEngine.getRuntime() method to verify it correctly retrieves
372+ // the AlluxioRuntime custom resource from the Kubernetes cluster.
373+ //
374+ // Test Structure:
375+ // - Defines a test table with multiple test cases (though currently only one example exists).
376+ // - Each test case specifies:
377+ // * Input fields: Simulated AlluxioEngine instance configuration.
378+ // * Expected output: The AlluxioRuntime object that should be returned.
379+ // * Error expectation: Whether an error is expected during retrieval.
380+ //
381+ // Key Testing Components:
382+ // - Uses Kubernetes client-go testing utilities (fake client, scheme registration) to mock
383+ // API server interactions, avoiding real cluster dependencies.
384+ // - Validates both successful retrieval and error conditions.
385+ // - Checks deep equality between retrieved and expected objects to ensure metadata accuracy.
386+ //
387+ // Test Workflow for Each Case:
388+ // 1. Register required Kubernetes resource types (AlluxioRuntime, core v1) into the scheme.
389+ // 2. Initialize a fake client preloaded with the expected AlluxioRuntime object.
390+ // 3. Instantiate the AlluxioEngine with test-specific configurations and the fake client.
391+ // 4. Execute getRuntime() and validate:
392+ // - Error behavior matches expectations
393+ // - Retrieved object matches the expected object structure exactly
394+ //
395+ // Edge Cases Covered (via additional test cases in TODO):
396+ // - Non-existent runtime
397+ // - Invalid namespace/name configurations
398+ // - API version/kind mismatches
399+ // - Cluster connection failures (simulated via client misconfiguration)
371400func TestGetRuntime (t * testing.T ) {
372401 type fields struct {
373402 runtime * datav1alpha1.AlluxioRuntime
0 commit comments