@@ -16,11 +16,12 @@ package util
1616
1717import (
1818 "fmt"
19- "github.com/opensds/opensds/pkg/utils"
2019 "reflect"
2120 "strconv"
2221 "testing"
2322
23+ "github.com/opensds/opensds/pkg/utils"
24+
2425 "github.com/opensds/opensds/pkg/context"
2526 "github.com/opensds/opensds/pkg/db"
2627 "github.com/opensds/opensds/pkg/model"
@@ -433,7 +434,7 @@ func TestCreateFileShareDBEntry(t *testing.T) {
433434 })
434435
435436 t .Run ("File share name length equal to 0 character are not allowed" , func (t * testing.T ) {
436- in .Name = utils .RandomString (0 )
437+ in .Name = utils .RandSeqWithAlnum (0 )
437438 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
438439 mockClient := new (dbtest.Client )
439440 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
@@ -445,7 +446,7 @@ func TestCreateFileShareDBEntry(t *testing.T) {
445446 })
446447
447448 t .Run ("File share name length equal to 1 character are allowed" , func (t * testing.T ) {
448- in .Name = utils .RandomString (1 )
449+ in .Name = utils .RandSeqWithAlnum (1 )
449450 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
450451 mockClient := new (dbtest.Client )
451452 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
@@ -460,7 +461,7 @@ func TestCreateFileShareDBEntry(t *testing.T) {
460461 })
461462
462463 t .Run ("File share name length equal to 10 characters are allowed" , func (t * testing.T ) {
463- in .Name = utils .RandomString (10 )
464+ in .Name = utils .RandSeqWithAlnum (10 )
464465 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
465466 mockClient := new (dbtest.Client )
466467 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
@@ -475,7 +476,7 @@ func TestCreateFileShareDBEntry(t *testing.T) {
475476 })
476477
477478 t .Run ("File share name length equal to 254 characters are allowed" , func (t * testing.T ) {
478- in .Name = utils .RandomString (254 )
479+ in .Name = utils .RandSeqWithAlnum (254 )
479480 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
480481 mockClient := new (dbtest.Client )
481482 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
@@ -490,7 +491,7 @@ func TestCreateFileShareDBEntry(t *testing.T) {
490491 })
491492
492493 t .Run ("File share name length equal to 255 characters are allowed" , func (t * testing.T ) {
493- in .Name = utils .RandomString (255 )
494+ in .Name = utils .RandSeqWithAlnum (255 )
494495 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
495496 mockClient := new (dbtest.Client )
496497 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
@@ -505,26 +506,26 @@ func TestCreateFileShareDBEntry(t *testing.T) {
505506 })
506507
507508 t .Run ("File share name length more than 255 characters are not allowed" , func (t * testing.T ) {
508- in .Name = utils .RandomString (256 )
509+ in .Name = utils .RandSeqWithAlnum (256 )
509510 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
510511 mockClient := new (dbtest.Client )
511512 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
512513 db .C = mockClient
513514
514515 _ , err := CreateFileShareDBEntry (context .NewAdminContext (), in )
515- expectedError := "fileshare name length should not be more than 255 characters. input name length is : " + strconv .Itoa (len (in .Name ))
516+ expectedError := "fileshare name length should not be more than 255 characters. input name length is : " + strconv .Itoa (len (in .Name ))
516517 assertTestResult (t , err .Error (), expectedError )
517518 })
518519
519520 t .Run ("File share name length more than 255 characters are not allowed" , func (t * testing.T ) {
520- in .Name = utils .RandomString (257 )
521+ in .Name = utils .RandSeqWithAlnum (257 )
521522 in .Size , in .ProfileId = int64 (1 ), "b3585ebe-c42c-120g-b28e-f373746a71ca"
522523 mockClient := new (dbtest.Client )
523524 mockClient .On ("CreateFileShare" , context .NewAdminContext (), in ).Return (& SampleFileShares [0 ], nil )
524525 db .C = mockClient
525526
526527 _ , err := CreateFileShareDBEntry (context .NewAdminContext (), in )
527- expectedError := "fileshare name length should not be more than 255 characters. input name length is : " + strconv .Itoa (len (in .Name ))
528+ expectedError := "fileshare name length should not be more than 255 characters. input name length is : " + strconv .Itoa (len (in .Name ))
528529 assertTestResult (t , err .Error (), expectedError )
529530 })
530531
0 commit comments