@@ -61,7 +61,7 @@ func TestUnwrap(t *testing.T) {
6161}
6262
6363func TestGetLabel (t * testing.T ) {
64- //when the instance label exist
64+ // when the instance label exist.
6565 {
6666 testMysqlCluster := mysqlCluster
6767 testMysqlCluster .Annotations = map [string ]string {
@@ -80,7 +80,7 @@ func TestGetLabel(t *testing.T) {
8080 }
8181 assert .Equal (t , want , testCase .GetLabels ())
8282 }
83- //when the component label exist
83+ // when the component label exist.
8484 {
8585 testMysqlCluster := mysqlCluster
8686 testMysqlCluster .Annotations = map [string ]string {
@@ -99,7 +99,7 @@ func TestGetLabel(t *testing.T) {
9999 }
100100 assert .Equal (t , want , testCase .GetLabels ())
101101 }
102- //when the part-of label exist
102+ // when the part-of label exist.
103103 {
104104 testMysqlCluster := mysqlCluster
105105 testMysqlCluster .Annotations = map [string ]string {
@@ -131,7 +131,7 @@ func TestGetSelectorLabels(t *testing.T) {
131131}
132132
133133func TestGetMySQLVersion (t * testing.T ) {
134- //other 8.0 -> 5.7.33
134+ // other 8.0 -> 5.7.33
135135 {
136136 testMysqlCluster := mysqlCluster
137137 testMysqlCluster .Spec .MysqlVersion = "8.0"
@@ -141,7 +141,7 @@ func TestGetMySQLVersion(t *testing.T) {
141141 want := "5.7.33"
142142 assert .Equal (t , want , testCase .GetMySQLVersion ())
143143 }
144- //MySQLTagsToSemVer 5.7 -> 5.7.33
144+ // MySQLTagsToSemVer 5.7 -> 5.7.33
145145 {
146146 testMysqlCluster := mysqlCluster
147147 testMysqlCluster .Spec .MysqlVersion = "5.7"
@@ -151,7 +151,7 @@ func TestGetMySQLVersion(t *testing.T) {
151151 want := "5.7.33"
152152 assert .Equal (t , want , testCase .GetMySQLVersion ())
153153 }
154- //MysqlImageVersions 5.7.33 -> 5.7.33
154+ // MysqlImageVersions 5.7.33 -> 5.7.33
155155 {
156156 testMysqlCluster := mysqlCluster
157157 testMysqlCluster .Spec .MysqlVersion = "5.7.33"
@@ -284,7 +284,7 @@ func TestEnsureVolumes(t *testing.T) {
284284 },
285285 },
286286 }
287- //when disable Persistence
287+ // when disable Persistence
288288 {
289289 testMysql := mysqlCluster
290290 testMysql .Spec .Persistence .Enabled = false
@@ -302,7 +302,7 @@ func TestEnsureVolumes(t *testing.T) {
302302 want = append (want , volume ... )
303303 assert .Equal (t , want , testCase .EnsureVolumes ())
304304 }
305- //when enable tokudb
305+ // when enable tokudb
306306 {
307307 testMysql := mysqlCluster
308308 testMysql .Spec .Persistence .Enabled = true
@@ -323,7 +323,7 @@ func TestEnsureVolumes(t *testing.T) {
323323 want = append (want , volume ... )
324324 assert .Equal (t , want , testCase .EnsureVolumes ())
325325 }
326- //default(Persistence is turned on by default)
326+ // default(Persistence is turned on by default)
327327 {
328328 testMysql := mysqlCluster
329329 testMysql .Spec .Persistence .Enabled = true
@@ -336,14 +336,14 @@ func TestEnsureVolumes(t *testing.T) {
336336
337337func TestEnsureVolumeClaimTemplates (t * testing.T ) {
338338 var scheme runtime.Scheme
339- //when disable persistence
339+ // when disable persistence
340340 {
341341 result , err := testCluster .EnsureVolumeClaimTemplates (& scheme )
342342 assert .Nil (t , result )
343343 assert .Nil (t , err )
344344 }
345345
346- //when enable persistence
346+ // when enable persistence
347347 {
348348 var cluster * Cluster
349349 storageClass := "ssd"
@@ -400,7 +400,7 @@ func TestEnsureVolumeClaimTemplates(t *testing.T) {
400400 assert .Nil (t , err )
401401 }
402402
403- //when the StorageClass is "-"
403+ // when the StorageClass is "-"
404404 {
405405 storageClass := "-"
406406 testMysql := mysqlCluster
@@ -420,7 +420,7 @@ func TestEnsureVolumeClaimTemplates(t *testing.T) {
420420 assert .Nil (t , err )
421421 }
422422
423- //when SetControllerReference error
423+ // when SetControllerReference error
424424 {
425425 testMysql := mysqlCluster
426426 testMysql .Spec .Persistence .Enabled = true
@@ -440,29 +440,29 @@ func TestEnsureVolumeClaimTemplates(t *testing.T) {
440440}
441441
442442func TestGetNameForResource (t * testing.T ) {
443- //statefulset configMap headlessSvc
443+ // statefulset configMap headlessSvc
444444 {
445445 want := "sample-mysql"
446446 assert .Equal (t , want , testCluster .GetNameForResource (utils .StatefulSet ))
447447 assert .Equal (t , want , testCluster .GetNameForResource (utils .ConfigMap ))
448448 assert .Equal (t , want , testCluster .GetNameForResource (utils .HeadlessSVC ))
449449 }
450- //leaderSvc
450+ // leaderSvc
451451 {
452452 want := "sample-leader"
453453 assert .Equal (t , want , testCluster .GetNameForResource (utils .LeaderService ))
454454 }
455- //folloerSvc
455+ // folloerSvc
456456 {
457457 want := "sample-follower"
458458 assert .Equal (t , want , testCluster .GetNameForResource (utils .FollowerService ))
459459 }
460- //secret
460+ // secret
461461 {
462462 want := "sample-secret"
463463 assert .Equal (t , want , testCluster .GetNameForResource (utils .Secret ))
464464 }
465- //others
465+ // others
466466 {
467467 want := "sample"
468468 assert .Equal (t , want , testCluster .GetNameForResource ("others" ))
@@ -496,7 +496,7 @@ func TestEnsureMysqlConf(t *testing.T) {
496496 },
497497 },
498498 }
499- //cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size not set
499+ // cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size not set
500500 {
501501 testMysqlCase := testMysql
502502 testCase := Cluster {
@@ -508,7 +508,7 @@ func TestEnsureMysqlConf(t *testing.T) {
508508 assert .Equal (t , wantSize , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_size" ])
509509 assert .Equal (t , wantInstance , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_instances" ])
510510 }
511- //cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size 600 mb
511+ // cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size 600 mb
512512 {
513513 guard := Patch (sizeToBytes , func (s string ) (uint64 , error ) {
514514 return uint64 (600 * mb ), nil
@@ -526,7 +526,7 @@ func TestEnsureMysqlConf(t *testing.T) {
526526 assert .Equal (t , wantSize , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_size" ])
527527 assert .Equal (t , wantInstance , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_instances" ])
528528 }
529- //cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb
529+ // cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb
530530 {
531531 guard := Patch (sizeToBytes , func (s string ) (uint64 , error ) {
532532 return uint64 (1700 * mb ), nil
@@ -546,7 +546,7 @@ func TestEnsureMysqlConf(t *testing.T) {
546546 assert .Equal (t , wantSize , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_size" ])
547547 assert .Equal (t , wantInstance , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_instances" ])
548548 }
549- //cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb, sizeToBytes error
549+ // cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb, sizeToBytes error
550550 {
551551 guard := Patch (sizeToBytes , func (s string ) (uint64 , error ) {
552552 return uint64 (1700 * mb ), fmt .Errorf ("error" )
@@ -565,7 +565,7 @@ func TestEnsureMysqlConf(t *testing.T) {
565565 assert .Equal (t , wantSize , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_size" ])
566566 assert .Equal (t , wantInstance , testCase .Spec .MysqlOpts .MysqlConf ["innodb_buffer_pool_instances" ])
567567 }
568- //cpu 8 corev1s,memory 16 gb,innodb_buffer_pool_size 2 gb
568+ // cpu 8 corev1s,memory 16 gb,innodb_buffer_pool_size 2 gb
569569 {
570570 guard := Patch (sizeToBytes , func (s string ) (uint64 , error ) {
571571 return uint64 (2 * gb ), nil
@@ -594,31 +594,31 @@ func TestSizeToBytes(t *testing.T) {
594594 mb int64 = 1 << 20
595595 kb int64 = 1 << 10
596596 )
597- //kb
597+ // kb
598598 {
599599 testCase := "1000k"
600600 want := uint64 (1000 * kb )
601601 result , err := sizeToBytes (testCase )
602602 assert .Equal (t , want , result )
603603 assert .Nil (t , err )
604604 }
605- //mb
605+ // mb
606606 {
607607 testCase := "1000m"
608608 want := uint64 (1000 * mb )
609609 result , err := sizeToBytes (testCase )
610610 assert .Equal (t , want , result )
611611 assert .Nil (t , err )
612612 }
613- //gb
613+ // gb
614614 {
615615 testCase := "1000g"
616616 want := uint64 (1000 * gb )
617617 result , err := sizeToBytes (testCase )
618618 assert .Equal (t , want , result )
619619 assert .Nil (t , err )
620620 }
621- //others
621+ // others
622622 {
623623 testCase := "1000a"
624624 want := uint64 (0 )
@@ -627,7 +627,7 @@ func TestSizeToBytes(t *testing.T) {
627627 assert .Equal (t , want , result )
628628 assert .Equal (t , wantError , err )
629629 }
630- //it will return the result of ParseUint() when the parameter without unit
630+ // it will return the result of ParseUint() when the parameter without unit
631631 {
632632 guard := Patch (strconv .ParseUint , func (s string , base int , bitSize int ) (uint64 , error ) {
633633 return uint64 (666 ), nil
@@ -640,7 +640,7 @@ func TestSizeToBytes(t *testing.T) {
640640 assert .Equal (t , want , result )
641641 assert .Nil (t , err )
642642 }
643- //ParseUint error
643+ // ParseUint error
644644 {
645645 guard := Patch (strconv .ParseUint , func (s string , base int , bitSize int ) (uint64 , error ) {
646646 return uint64 (777 ), fmt .Errorf ("error" )
0 commit comments