@@ -33,6 +33,7 @@ import (
3333// Return value:
3434// - None (this is a test function, and it does not return any values).
3535func TestTransformDatasetToVolume (t * testing.T ) {
36+ // Initialize UFSPath variables for expected results.
3637 var ufsPath = UFSPath {}
3738 ufsPath .Name = "test"
3839 ufsPath .HostPath = "/mnt/test"
@@ -43,12 +44,14 @@ func TestTransformDatasetToVolume(t *testing.T) {
4344 ufsPath1 .HostPath = "/mnt/test"
4445 ufsPath1 .ContainerPath = "/underFSStorage"
4546
47+ // Define test cases with different Dataset configurations
4648 var tests = []struct {
4749 runtime * datav1alpha1.AlluxioRuntime
4850 dataset * datav1alpha1.Dataset
4951 value * Alluxio
5052 expect UFSPath
5153 }{
54+ // Test case 1: Simple Mount configuration
5255 {& datav1alpha1.AlluxioRuntime {}, & datav1alpha1.Dataset {
5356 Spec : datav1alpha1.DatasetSpec {
5457 Mounts : []datav1alpha1.Mount {{
@@ -57,6 +60,8 @@ func TestTransformDatasetToVolume(t *testing.T) {
5760 }},
5861 },
5962 }, & Alluxio {}, ufsPath },
63+
64+ // Test case 2: Mount with a path specified
6065 {& datav1alpha1.AlluxioRuntime {}, & datav1alpha1.Dataset {
6166 Spec : datav1alpha1.DatasetSpec {
6267 Mounts : []datav1alpha1.Mount {{
@@ -67,11 +72,17 @@ func TestTransformDatasetToVolume(t *testing.T) {
6772 },
6873 }, & Alluxio {}, ufsPath1 },
6974 }
75+
76+ // Iterate through all test cases and run the test.
7077 for _ , test := range tests {
78+ // Create an instance of AlluxioEngine to call the function under test.
7179 engine := & AlluxioEngine {}
80+ // Call the function that we want to test.
7281 engine .transformDatasetToVolume (test .runtime , test .dataset , test .value )
82+ // Compare the actual result with the expected result.
7383 if test .value .UFSPaths [0 ].HostPath != test .expect .HostPath ||
7484 test .value .UFSPaths [0 ].ContainerPath != test .expect .ContainerPath {
85+ // If the result doesn't match the expected values, report an error.
7586 t .Errorf ("expected %v, got %v" , test .expect , test .value .UFSPaths [0 ])
7687 }
7788 }
0 commit comments