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)
| 381 | // Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects, |
| 382 | // and map of MockContainerHandler objects.} |
| 383 | func expectManagerWithContainersV2(containers []string, query *info.ContainerInfoRequest, t *testing.T) (*manager, map[string]*info.ContainerInfo, map[string]*containertest.MockContainerHandler) { |
| 384 | infosMap := make(map[string]*info.ContainerInfo, len(containers)) |
| 385 | handlerMap := make(map[string]*containertest.MockContainerHandler, len(containers)) |
| 386 | |
| 387 | for _, container := range containers { |
| 388 | infosMap[container] = itest.GenerateRandomContainerInfo(container, 4, query, 1*time.Second) |
| 389 | } |
| 390 | |
| 391 | memoryCache := memory.New(time.Duration(query.NumStats)*time.Second, nil) |
| 392 | sysfs := &fakesysfs.FakeSysFs{} |
| 393 | m := createManagerAndAddContainers( |
| 394 | memoryCache, |
| 395 | sysfs, |
| 396 | containers, |
| 397 | func(h *containertest.MockContainerHandler) { |
| 398 | cinfo := infosMap[h.Name] |
| 399 | ref, err := h.ContainerReference() |
| 400 | if err != nil { |
| 401 | t.Error(err) |
| 402 | } |
| 403 | |
| 404 | cInfo := info.ContainerInfo{ |
| 405 | ContainerReference: ref, |
| 406 | } |
| 407 | |
| 408 | for _, stat := range cinfo.Stats { |
| 409 | err = memoryCache.AddStats(&cInfo, stat) |
| 410 | if err != nil { |
| 411 | t.Error(err) |
| 412 | } |
| 413 | } |
| 414 | spec := cinfo.Spec |
| 415 | |
| 416 | h.On("GetSpec").Return( |
| 417 | spec, |
| 418 | nil, |
| 419 | ).Once() |
| 420 | handlerMap[h.Name] = h |
| 421 | }, |
| 422 | t, |
| 423 | ) |
| 424 | |
| 425 | return m, infosMap, handlerMap |
| 426 | } |
| 427 | |
| 428 | func TestGetContainerInfoV2(t *testing.T) { |
| 429 | containers := []string{ |
no test coverage detected
searching dependent graphs…