@@ -29,6 +29,56 @@ const (
2929 TraceStr = "trace"
3030)
3131
32+ func TestRemoveBucketSuffixIfPresentAndReturnVolumeId (t * testing.T ) {
33+ t .Parallel ()
34+ t .Run ("removing bucket suffix if present and returning volume id" , func (t * testing.T ) {
35+ t .Parallel ()
36+ testCases := []struct {
37+ name string
38+ bucketName string
39+ expectedValue string
40+ }{
41+ {
42+ name : "should return bucket name without suffix, no special character" ,
43+ bucketName : "bucket-name:1234567890123456789" ,
44+ expectedValue : "bucket-name" ,
45+ },
46+ {
47+ name : "should return bucket name without suffix, special character" ,
48+ bucketName : "bucket-name:1234567890123456789@us-central1" ,
49+ expectedValue : "bucket-name" ,
50+ },
51+ {
52+ name : "should return bucket name without suffix, no colon with special character" ,
53+ bucketName : "bucket-name@us-central1" ,
54+ expectedValue : "bucket-name@us-central1" ,
55+ },
56+ {
57+ name : "should return bucket name without suffix, two colons" ,
58+ bucketName : "bucket-name:1234567890123456789:12" ,
59+ expectedValue : "bucket-name" ,
60+ },
61+ {
62+ name : "should return bucket name without suffix, no special character and no colon" ,
63+ bucketName : "bucket-name" ,
64+ expectedValue : "bucket-name" ,
65+ },
66+ {
67+ name : "should return bucket name without suffix, no bucket name" ,
68+ bucketName : ":xyz" ,
69+ expectedValue : "" ,
70+ },
71+ }
72+
73+ for _ , tc := range testCases {
74+ t .Logf ("test case: %s" , tc .name )
75+ actual := parseVolumeID (tc .bucketName )
76+ if actual != tc .expectedValue {
77+ t .Errorf ("Got value %v, but expected %v" , actual , tc .expectedValue )
78+ }
79+ }
80+ })
81+ }
3282func TestJoinMountOptions (t * testing.T ) {
3383 t .Parallel ()
3484 t .Run ("joining mount options into one" , func (t * testing.T ) {
0 commit comments