@@ -160,7 +160,7 @@ func TestDeleteComponentClient_ListClusterResourcesToDelete(t *testing.T) {
160
160
ctrl := gomock .NewController (t )
161
161
kubeClient := tt .fields .kubeClient (ctrl )
162
162
execClient := exec .NewExecClient (kubeClient )
163
- do := NewDeleteComponentClient (kubeClient , nil , execClient )
163
+ do := NewDeleteComponentClient (kubeClient , nil , execClient , nil )
164
164
ctx := odocontext .WithApplication (context .TODO (), "app" )
165
165
got , err := do .ListClusterResourcesToDelete (ctx , tt .args .componentName , tt .args .namespace , tt .args .mode )
166
166
if (err != nil ) != tt .wantErr {
@@ -277,7 +277,7 @@ func TestDeleteComponentClient_DeleteResources(t *testing.T) {
277
277
ctrl := gomock .NewController (t )
278
278
kubeClient := tt .fields .kubeClient (ctrl )
279
279
execClient := exec .NewExecClient (kubeClient )
280
- do := NewDeleteComponentClient (kubeClient , nil , execClient )
280
+ do := NewDeleteComponentClient (kubeClient , nil , execClient , nil )
281
281
got := do .DeleteResources (tt .args .resources , false )
282
282
if diff := cmp .Diff (tt .want , got ); diff != "" {
283
283
t .Errorf ("DeleteComponentClient.DeleteResources() mismatch (-want +got):\n %s" , diff )
@@ -686,10 +686,10 @@ func TestDeleteComponentClient_ExecutePreStopEvents(t *testing.T) {
686
686
client := kclient .NewMockClientInterface (ctrl )
687
687
688
688
selector := odolabels .GetSelector (componentName , "app" , odolabels .ComponentDevMode , false )
689
- client .EXPECT ().GetRunningPodFromSelector (selector ).Return (odoTestingUtil .CreateFakePod (componentName , "runtime" ), nil )
689
+ client .EXPECT ().GetRunningPodFromSelector (selector ).Return (odoTestingUtil .CreateFakePod (componentName , "mypod" , " runtime" ), nil )
690
690
691
691
cmd := []string {"/bin/sh" , "-c" , "cd /projects/nodejs-starter && (echo \" Hello World!\" ) 1>>/proc/1/fd/1 2>>/proc/1/fd/2" }
692
- client .EXPECT ().ExecCMDInContainer (gomock .Any (), "runtime" , "runtime " , cmd , gomock .Any (), gomock .Any (), nil , false ).Return (nil )
692
+ client .EXPECT ().ExecCMDInContainer (gomock .Any (), "runtime" , "mypod " , cmd , gomock .Any (), gomock .Any (), nil , false ).Return (nil )
693
693
694
694
return client
695
695
},
@@ -707,7 +707,7 @@ func TestDeleteComponentClient_ExecutePreStopEvents(t *testing.T) {
707
707
client := kclient .NewMockClientInterface (ctrl )
708
708
709
709
selector := odolabels .GetSelector (componentName , "app" , odolabels .ComponentDevMode , false )
710
- pod := odoTestingUtil .CreateFakePod (componentName , "runtime" )
710
+ pod := odoTestingUtil .CreateFakePod (componentName , "mypod" , " runtime" )
711
711
pod .Status .Phase = corev1 .PodFailed
712
712
client .EXPECT ().GetRunningPodFromSelector (selector ).Return (pod , nil )
713
713
return client
@@ -726,14 +726,14 @@ func TestDeleteComponentClient_ExecutePreStopEvents(t *testing.T) {
726
726
client := kclient .NewMockClientInterface (ctrl )
727
727
728
728
selector := odolabels .GetSelector (componentName , "app" , odolabels .ComponentDevMode , false )
729
- fakePod := odoTestingUtil .CreateFakePod (componentName , "runtime" )
729
+ fakePod := odoTestingUtil .CreateFakePod (componentName , "mypod" , " runtime" )
730
730
// Expecting this method to be called twice because if the command execution fails, we try to get the pod logs by calling GetOnePodFromSelector again.
731
731
client .EXPECT ().GetRunningPodFromSelector (selector ).Return (fakePod , nil ).Times (2 )
732
732
733
733
client .EXPECT ().GetPodLogs (fakePod .Name , gomock .Any (), gomock .Any ()).Return (nil , errors .New ("an error" ))
734
734
735
735
cmd := []string {"/bin/sh" , "-c" , "cd /projects/nodejs-starter && (echo \" Hello World!\" ) 1>>/proc/1/fd/1 2>>/proc/1/fd/2" }
736
- client .EXPECT ().ExecCMDInContainer (gomock .Any (), "runtime" , "runtime " , cmd , gomock .Any (), gomock .Any (), nil , false ).Return (errors .New ("some error" ))
736
+ client .EXPECT ().ExecCMDInContainer (gomock .Any (), "runtime" , "mypod " , cmd , gomock .Any (), gomock .Any (), nil , false ).Return (errors .New ("some error" ))
737
737
738
738
return client
739
739
},
@@ -750,8 +750,11 @@ func TestDeleteComponentClient_ExecutePreStopEvents(t *testing.T) {
750
750
ctrl := gomock .NewController (t )
751
751
kubeClient := tt .fields .kubeClient (ctrl )
752
752
execClient := exec .NewExecClient (kubeClient )
753
- do := NewDeleteComponentClient (kubeClient , nil , execClient )
754
- if err := do .ExecutePreStopEvents (context .Background (), tt .args .devfileObj , tt .args .appName , tt .args .devfileObj .GetMetadataName ()); (err != nil ) != tt .wantErr {
753
+ do := NewDeleteComponentClient (kubeClient , nil , execClient , nil )
754
+ ctx := context .Background ()
755
+ ctx = odocontext .WithApplication (ctx , appName )
756
+ ctx = odocontext .WithComponentName (ctx , componentName )
757
+ if err := do .ExecutePreStopEvents (ctx , tt .args .devfileObj , tt .args .appName , tt .args .devfileObj .GetMetadataName ()); (err != nil ) != tt .wantErr {
755
758
t .Errorf ("DeleteComponent() error = %v, wantErr %v" , err , tt .wantErr )
756
759
}
757
760
})
0 commit comments