@@ -219,3 +219,51 @@ func TestContainerResourceExecutor_UpdateRequestForUpdateContainerResourcesReque
219219 assert .Equal (t , tt .wantAnnotations , tt .args .req .(* runtimeapi.UpdateContainerResourcesRequest ).GetAnnotations ())
220220 }
221221}
222+
223+ func TestContainerResourceExecutor_ResourceCheckPoint (t * testing.T ) {
224+ type fields struct {
225+ ContainerInfo store.ContainerInfo
226+ }
227+ type args struct {
228+ rsp interface {}
229+ }
230+ tests := []struct {
231+ name string
232+ fields fields
233+ args args
234+ wantErr bool
235+ wantStoreInfo * store.ContainerInfo
236+ }{
237+ {
238+ name : "normal case - CreateContainerResponse - Set Container id successfully" ,
239+ args : args {
240+ rsp : & runtimeapi.CreateContainerResponse {
241+ ContainerId : "111111" ,
242+ },
243+ },
244+ fields : fields {
245+ ContainerInfo : store.ContainerInfo {
246+ ContainerResourceHookRequest : & v1alpha1.ContainerResourceHookRequest {
247+ ContainerMata : & v1alpha1.ContainerMetadata {},
248+ },
249+ },
250+ },
251+ wantErr : false ,
252+ wantStoreInfo : & store.ContainerInfo {
253+ ContainerResourceHookRequest : & v1alpha1.ContainerResourceHookRequest {
254+ ContainerMata : & v1alpha1.ContainerMetadata {
255+ Id : "111111" ,
256+ },
257+ }},
258+ },
259+ }
260+ for _ , tt := range tests {
261+ c := & ContainerResourceExecutor {
262+ ContainerInfo : tt .fields .ContainerInfo ,
263+ }
264+ err := c .ResourceCheckPoint (tt .args .rsp )
265+ containerInfo := store .GetContainerInfo (c .ContainerInfo .ContainerMata .GetId ())
266+ assert .Equal (t , tt .wantErr , err != nil , err )
267+ assert .Equal (t , tt .wantStoreInfo , containerInfo )
268+ }
269+ }
0 commit comments