@@ -394,6 +394,14 @@ func TestAPI_CreateDeployApp(t *testing.T) {
394394 },
395395 },
396396 },
397+ {
398+ Name : "myregistrykey" ,
399+ VolumeSource : specV1.VolumeSource {
400+ Secret : & specV1.ObjectReference {
401+ Name : "myregistrykey" ,
402+ },
403+ },
404+ },
397405 },
398406 Replica : 1 ,
399407 Workload : "deployment" ,
@@ -412,8 +420,8 @@ func TestAPI_CreateDeployApp(t *testing.T) {
412420 }
413421 sApp .EXPECT ().Get ("default" , "nginx" , "" ).Return (nil , nil ).Times (1 )
414422 sConfig .EXPECT ().Get ("default" , "common-cm" , "" ).Return (cfg , nil ).Times (2 )
415- sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (2 )
416- sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (2 )
423+ sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (4 )
424+ sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (4 )
417425 sFacade .EXPECT ().CreateApp ("default" , nil , gomock .Any (), nil ).Return (deployApp , nil ).Times (1 )
418426
419427 buf := new (bytes.Buffer )
@@ -429,7 +437,7 @@ func TestAPI_CreateDeployApp(t *testing.T) {
429437 router .ServeHTTP (re , req )
430438 assert .Equal (t , http .StatusOK , re .Code )
431439
432- var resApp []specV1. Application
440+ var resApp []gmodels. ApplicationView
433441 body , err := ioutil .ReadAll (re .Body )
434442 assert .NilError (t , err )
435443 err = json .Unmarshal (body , & resApp )
@@ -440,7 +448,8 @@ func TestAPI_CreateDeployApp(t *testing.T) {
440448 resapp , err := api .generateDeployApp ("default" , deploy )
441449 resapp .Services [0 ].Resources .Limits = nil
442450 resapp .Services [0 ].Resources .Requests = nil
443- assert .DeepEqual (t , & resApp [0 ], resapp )
451+ appView , _ := api .ToApplicationView (resapp )
452+ assert .DeepEqual (t , & resApp [0 ], appView )
444453}
445454
446455func TestAPI_CreateDaemonSetApp (t * testing.T ) {
@@ -538,6 +547,14 @@ func TestAPI_CreateDaemonSetApp(t *testing.T) {
538547 },
539548 },
540549 },
550+ {
551+ Name : "myregistrykey" ,
552+ VolumeSource : specV1.VolumeSource {
553+ Secret : & specV1.ObjectReference {
554+ Name : "myregistrykey" ,
555+ },
556+ },
557+ },
541558 },
542559 Workload : "daemonset" ,
543560 }
@@ -555,8 +572,8 @@ func TestAPI_CreateDaemonSetApp(t *testing.T) {
555572 }
556573 sApp .EXPECT ().Get ("default" , "nginx" , "" ).Return (nil , nil ).Times (1 )
557574 sConfig .EXPECT ().Get ("default" , "common-cm" , "" ).Return (cfg , nil ).Times (2 )
558- sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (2 )
559- sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (2 )
575+ sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (4 )
576+ sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (4 )
560577 sFacade .EXPECT ().CreateApp ("default" , nil , gomock .Any (), nil ).Return (dsApp , nil ).Times (1 )
561578
562579 buf := new (bytes.Buffer )
@@ -572,7 +589,7 @@ func TestAPI_CreateDaemonSetApp(t *testing.T) {
572589 router .ServeHTTP (re , req )
573590 assert .Equal (t , http .StatusOK , re .Code )
574591
575- var resApp []specV1. Application
592+ var resApp []gmodels. ApplicationView
576593 body , err := ioutil .ReadAll (re .Body )
577594 assert .NilError (t , err )
578595 err = json .Unmarshal ([]byte (body ), & resApp )
@@ -581,7 +598,8 @@ func TestAPI_CreateDaemonSetApp(t *testing.T) {
581598 resources := api .parseK8SYaml ([]byte (testAppDs ))
582599 ds , _ := resources [0 ].(* appv1.DaemonSet )
583600 resapp , err := api .generateDaemonSetApp ("default" , ds )
584- assert .DeepEqual (t , & resApp [0 ], resapp )
601+ appView , _ := api .ToApplicationView (resapp )
602+ assert .DeepEqual (t , & resApp [0 ], appView )
585603}
586604
587605func TestAPI_CreateJobApp (t * testing.T ) {
@@ -642,7 +660,7 @@ func TestAPI_CreateJobApp(t *testing.T) {
642660 router .ServeHTTP (re , req )
643661 assert .Equal (t , http .StatusOK , re .Code )
644662
645- var resApp []specV1. Application
663+ var resApp []gmodels. ApplicationView
646664 body , err := ioutil .ReadAll (re .Body )
647665 assert .NilError (t , err )
648666 err = json .Unmarshal ([]byte (body ), & resApp )
@@ -652,7 +670,10 @@ func TestAPI_CreateJobApp(t *testing.T) {
652670 job , _ := resources [0 ].(* batchv1.Job )
653671 resapp , err := api .generateJobApp ("default" , job )
654672 resapp .Services [0 ].Resources = nil
655- assert .DeepEqual (t , & resApp [0 ], resapp )
673+ appView , _ := api .ToApplicationView (resapp )
674+ appView .Volumes = nil
675+ appView .Registries = nil
676+ assert .DeepEqual (t , & resApp [0 ], appView )
656677}
657678
658679func TestAPI_UpdateDeployApp (t * testing.T ) {
@@ -747,6 +768,14 @@ func TestAPI_UpdateDeployApp(t *testing.T) {
747768 },
748769 },
749770 },
771+ {
772+ Name : "myregistrykey" ,
773+ VolumeSource : specV1.VolumeSource {
774+ Secret : & specV1.ObjectReference {
775+ Name : "myregistrykey" ,
776+ },
777+ },
778+ },
750779 },
751780 Replica : 1 ,
752781 Workload : "deployment" ,
@@ -826,6 +855,14 @@ func TestAPI_UpdateDeployApp(t *testing.T) {
826855 },
827856 },
828857 },
858+ {
859+ Name : "myregistrykey" ,
860+ VolumeSource : specV1.VolumeSource {
861+ Secret : & specV1.ObjectReference {
862+ Name : "myregistrykey" ,
863+ },
864+ },
865+ },
829866 },
830867 Replica : 1 ,
831868 Workload : "deployment" ,
@@ -845,8 +882,8 @@ func TestAPI_UpdateDeployApp(t *testing.T) {
845882
846883 sApp .EXPECT ().Get ("default" , "nginx" , "" ).Return (expectApp , nil ).Times (1 )
847884 sConfig .EXPECT ().Get ("default" , "common-cm" , "" ).Return (cfg , nil ).Times (2 )
848- sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (2 )
849- sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (2 )
885+ sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (4 )
886+ sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (4 )
850887 sFacade .EXPECT ().UpdateApp ("default" , expectApp , gomock .Any (), nil ).Return (updateApp , nil ).Times (1 )
851888
852889 buf := new (bytes.Buffer )
@@ -862,7 +899,7 @@ func TestAPI_UpdateDeployApp(t *testing.T) {
862899 router .ServeHTTP (re , req )
863900 assert .Equal (t , http .StatusOK , re .Code )
864901
865- var resApp []specV1. Application
902+ var resApp []gmodels. ApplicationView
866903 body , err := ioutil .ReadAll (re .Body )
867904 assert .NilError (t , err )
868905 err = json .Unmarshal (body , & resApp )
@@ -873,7 +910,8 @@ func TestAPI_UpdateDeployApp(t *testing.T) {
873910 resapp , err := api .generateDeployApp ("default" , deploy )
874911 resapp .Services [0 ].Resources .Limits = nil
875912 resapp .Services [0 ].Resources .Requests = nil
876- assert .DeepEqual (t , & resApp [0 ], resapp )
913+ appView , _ := api .ToApplicationView (resapp )
914+ assert .DeepEqual (t , & resApp [0 ], appView )
877915}
878916
879917func TestAPI_UpdateDsApp (t * testing.T ) {
@@ -971,6 +1009,14 @@ func TestAPI_UpdateDsApp(t *testing.T) {
9711009 },
9721010 },
9731011 },
1012+ {
1013+ Name : "myregistrykey" ,
1014+ VolumeSource : specV1.VolumeSource {
1015+ Secret : & specV1.ObjectReference {
1016+ Name : "myregistrykey" ,
1017+ },
1018+ },
1019+ },
9741020 },
9751021 Workload : "daemonset" ,
9761022 }
@@ -1052,6 +1098,14 @@ func TestAPI_UpdateDsApp(t *testing.T) {
10521098 },
10531099 },
10541100 },
1101+ {
1102+ Name : "myregistrykey" ,
1103+ VolumeSource : specV1.VolumeSource {
1104+ Secret : & specV1.ObjectReference {
1105+ Name : "myregistrykey" ,
1106+ },
1107+ },
1108+ },
10551109 },
10561110 Workload : "daemonset" ,
10571111 }
@@ -1070,8 +1124,8 @@ func TestAPI_UpdateDsApp(t *testing.T) {
10701124
10711125 sApp .EXPECT ().Get ("default" , "nginx" , "" ).Return (dsApp , nil ).Times (1 )
10721126 sConfig .EXPECT ().Get ("default" , "common-cm" , "" ).Return (cfg , nil ).Times (2 )
1073- sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (2 )
1074- sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (2 )
1127+ sSecret .EXPECT ().Get ("default" , "dcell" , "" ).Return (secret , nil ).Times (4 )
1128+ sSecret .EXPECT ().Get ("default" , "myregistrykey" , "" ).Return (registry , nil ).Times (4 )
10751129 sFacade .EXPECT ().UpdateApp ("default" , dsApp , gomock .Any (), nil ).Return (updateApp , nil ).Times (1 )
10761130
10771131 buf := new (bytes.Buffer )
@@ -1087,7 +1141,7 @@ func TestAPI_UpdateDsApp(t *testing.T) {
10871141 router .ServeHTTP (re , req )
10881142 assert .Equal (t , http .StatusOK , re .Code )
10891143
1090- var resApp []specV1. Application
1144+ var resApp []gmodels. ApplicationView
10911145 body , err := ioutil .ReadAll (re .Body )
10921146 assert .NilError (t , err )
10931147 err = json .Unmarshal (body , & resApp )
@@ -1096,7 +1150,8 @@ func TestAPI_UpdateDsApp(t *testing.T) {
10961150 resources := api .parseK8SYaml ([]byte (updateAppDs ))
10971151 ds , _ := resources [0 ].(* appv1.DaemonSet )
10981152 resapp , err := api .generateDaemonSetApp ("default" , ds )
1099- assert .DeepEqual (t , & resApp [0 ], resapp )
1153+ appView , _ := api .ToApplicationView (resapp )
1154+ assert .DeepEqual (t , & resApp [0 ], appView )
11001155}
11011156
11021157func TestAPI_UpdateJobApp (t * testing.T ) {
@@ -1181,7 +1236,7 @@ func TestAPI_UpdateJobApp(t *testing.T) {
11811236 router .ServeHTTP (re , req )
11821237 assert .Equal (t , http .StatusOK , re .Code )
11831238
1184- var resApp []specV1. Application
1239+ var resApp []gmodels. ApplicationView
11851240 body , err := ioutil .ReadAll (re .Body )
11861241 assert .NilError (t , err )
11871242 err = json .Unmarshal (body , & resApp )
@@ -1191,7 +1246,10 @@ func TestAPI_UpdateJobApp(t *testing.T) {
11911246 job , _ := resources [0 ].(* batchv1.Job )
11921247 resapp , err := api .generateJobApp ("default" , job )
11931248 resapp .Services [0 ].Resources = nil
1194- assert .DeepEqual (t , & resApp [0 ], resapp )
1249+ appView , _ := api .ToApplicationView (resapp )
1250+ appView .Registries = nil
1251+ appView .Volumes = nil
1252+ assert .DeepEqual (t , & resApp [0 ], appView )
11951253}
11961254
11971255func TestAPI_DeleteApp (t * testing.T ) {
0 commit comments