Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects, and map of MockContainerHandler objects.}
(containers []string, query *info.ContainerInfoRequest, t *testing.T)
| 336 | // Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects, |
| 337 | // and map of MockContainerHandler objects.} |
| 338 | func expectManagerWithSubContainers(containers []string, query *info.ContainerInfoRequest, t *testing.T) (*manager, map[string]*info.ContainerInfo, map[string]*containertest.MockContainerHandler) { |
| 339 | infosMap := make(map[string]*info.ContainerInfo, len(containers)) |
| 340 | handlerMap := make(map[string]*containertest.MockContainerHandler, len(containers)) |
| 341 | |
| 342 | for _, container := range containers { |
| 343 | infosMap[container] = itest.GenerateRandomContainerInfo(container, 4, query, 1*time.Second) |
| 344 | } |
| 345 | |
| 346 | memoryCache := memory.New(time.Duration(query.NumStats)*time.Second, nil) |
| 347 | sysfs := &fakesysfs.FakeSysFs{} |
| 348 | m := createManagerAndAddSubContainers( |
| 349 | memoryCache, |
| 350 | sysfs, |
| 351 | containers, |
| 352 | func(h *containertest.MockContainerHandler) { |
| 353 | cinfo := infosMap[h.Name] |
| 354 | ref, err := h.ContainerReference() |
| 355 | if err != nil { |
| 356 | t.Error(err) |
| 357 | } |
| 358 | |
| 359 | cInfo := info.ContainerInfo{ |
| 360 | ContainerReference: ref, |
| 361 | } |
| 362 | for _, stat := range cinfo.Stats { |
| 363 | err = memoryCache.AddStats(&cInfo, stat) |
| 364 | if err != nil { |
| 365 | t.Error(err) |
| 366 | } |
| 367 | } |
| 368 | spec := cinfo.Spec |
| 369 | h.On("GetSpec").Return( |
| 370 | spec, |
| 371 | nil, |
| 372 | ).Once() |
| 373 | handlerMap[h.Name] = h |
| 374 | }, |
| 375 | t, |
| 376 | ) |
| 377 | |
| 378 | return m, infosMap, handlerMap |
| 379 | } |
| 380 | |
| 381 | // Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects, |
| 382 | // and map of MockContainerHandler objects.} |
no test coverage detected
searching dependent graphs…