@@ -556,6 +556,64 @@ func Test_Image_ExecutorOptions_UnmarshalJSON(t *testing.T) {
556
556
}
557
557
}
558
558
559
+ func Test_Image_ExecutorOptions_GetUIDGID (t * testing.T ) {
560
+ tests := map [string ]struct {
561
+ kubernetesOptions func () * ImageKubernetesOptions
562
+ expectedError bool
563
+ expectedUID int64
564
+ expectedGID int64
565
+ }{
566
+ "empty user" : {
567
+ kubernetesOptions : func () * ImageKubernetesOptions {
568
+ return & ImageKubernetesOptions {
569
+ User : "" ,
570
+ }
571
+ },
572
+ },
573
+ "only user" : {
574
+ kubernetesOptions : func () * ImageKubernetesOptions {
575
+ return & ImageKubernetesOptions {
576
+ User : "1000" ,
577
+ }
578
+ },
579
+ expectedUID : int64 (1000 ),
580
+ },
581
+ "uid and gid" : {
582
+ kubernetesOptions : func () * ImageKubernetesOptions {
583
+ return & ImageKubernetesOptions {
584
+ User : "1000:1000" ,
585
+ }
586
+ },
587
+ expectedUID : int64 (1000 ),
588
+ expectedGID : int64 (1000 ),
589
+ },
590
+ "invalid user" : {
591
+ kubernetesOptions : func () * ImageKubernetesOptions {
592
+ return & ImageKubernetesOptions {
593
+ User : "gitlab-runner" ,
594
+ }
595
+ },
596
+ expectedError : true ,
597
+ },
598
+ }
599
+
600
+ for name , tt := range tests {
601
+ t .Run (name , func (t * testing.T ) {
602
+ uid , gid , err := tt .kubernetesOptions ().GetUIDGID ()
603
+ if tt .expectedError {
604
+ require .Error (t , err )
605
+ require .Equal (t , int64 (0 ), uid )
606
+ require .Equal (t , int64 (0 ), gid )
607
+ return
608
+ }
609
+
610
+ require .NoError (t , err )
611
+ require .Equal (t , tt .expectedUID , uid )
612
+ require .Equal (t , tt .expectedGID , gid )
613
+ })
614
+ }
615
+ }
616
+
559
617
func TestJobResponse_Run (t * testing.T ) {
560
618
tests := map [string ]struct {
561
619
json string
0 commit comments