@@ -21,3 +21,64 @@ func TestFnvHashTest(t *testing.T) {
2121 }
2222 }
2323}
24+
25+ func TestCalculateMD5Hash (t * testing.T ) {
26+ type args struct {
27+ value any
28+ }
29+ tests := []struct {
30+ name string
31+ args args
32+ want string
33+ }{
34+ {
35+ name : "RBD with empty CephFSID" ,
36+ args : args {
37+ value : [2 ]string {"" , "" },
38+ },
39+ want : "2432510f5993984b053e7d74ce53d94c" ,
40+ },
41+ {
42+ name : "CephFS with empty CephFSID" ,
43+ args : args {
44+ value : [2 ]string {"" , "csi" },
45+ },
46+ want : "793b48b9b17bdad5cd141e6daadfdd4e" ,
47+ },
48+ {
49+ name : "C1/RBD" ,
50+ args : args {
51+ value : [2 ]string {"a0eaa723-bf87-48db-ad11-17e276edda61" , "" },
52+ },
53+ want : "bb2361459436fd47121419c658d4c79b" ,
54+ },
55+ {
56+ name : "C1/CephFS" ,
57+ args : args {
58+ value : [2 ]string {"a0eaa723-bf87-48db-ad11-17e276edda61" , "csi" },
59+ },
60+ want : "41711cb35464e85f4446ace583adbaa1" ,
61+ },
62+ {
63+ name : "C2/RBD" ,
64+ args : args {
65+ value : [2 ]string {"30dc85db-f35f-4c03-bb43-c8592487d8b9" , "" },
66+ },
67+ want : "9e4fbb3d9e52875d6393409a51927243" ,
68+ },
69+ {
70+ name : "C2/CephFS" ,
71+ args : args {
72+ value : [2 ]string {"30dc85db-f35f-4c03-bb43-c8592487d8b9" , "csi" },
73+ },
74+ want : "4b7e331b508946ca7165f14804c37ffc" ,
75+ },
76+ }
77+ for _ , tt := range tests {
78+ t .Run (tt .name , func (t * testing.T ) {
79+ if got := CalculateMD5Hash (tt .args .value ); got != tt .want {
80+ t .Errorf ("CalculateMD5Hash() = %v, want %v" , got , tt .want )
81+ }
82+ })
83+ }
84+ }
0 commit comments