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)
| 286 | // Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects, |
| 287 | // and map of MockContainerHandler objects.} |
| 288 | func expectManagerWithContainers(containers []string, query *info.ContainerInfoRequest, t *testing.T) (*manager, map[string]*info.ContainerInfo, map[string]*containertest.MockContainerHandler) { |
| 289 | infosMap := make(map[string]*info.ContainerInfo, len(containers)) |
| 290 | handlerMap := make(map[string]*containertest.MockContainerHandler, len(containers)) |
| 291 | |
| 292 | for _, container := range containers { |
| 293 | infosMap[container] = itest.GenerateRandomContainerInfo(container, 4, query, 1*time.Second) |
| 294 | } |
| 295 | |
| 296 | memoryCache := memory.New(time.Duration(query.NumStats)*time.Second, nil) |
| 297 | sysfs := &fakesysfs.FakeSysFs{} |
| 298 | m := createManagerAndAddContainers( |
| 299 | memoryCache, |
| 300 | sysfs, |
| 301 | containers, |
| 302 | func(h *containertest.MockContainerHandler) { |
| 303 | cinfo := infosMap[h.Name] |
| 304 | ref, err := h.ContainerReference() |
| 305 | if err != nil { |
| 306 | t.Error(err) |
| 307 | } |
| 308 | |
| 309 | cInfo := info.ContainerInfo{ |
| 310 | ContainerReference: ref, |
| 311 | } |
| 312 | for _, stat := range cinfo.Stats { |
| 313 | err = memoryCache.AddStats(&cInfo, stat) |
| 314 | if err != nil { |
| 315 | t.Error(err) |
| 316 | } |
| 317 | } |
| 318 | spec := cinfo.Spec |
| 319 | |
| 320 | h.On("ListContainers", container.ListSelf).Return( |
| 321 | []info.ContainerReference(nil), |
| 322 | nil, |
| 323 | ) |
| 324 | h.On("GetSpec").Return( |
| 325 | spec, |
| 326 | nil, |
| 327 | ).Once() |
| 328 | handlerMap[h.Name] = h |
| 329 | }, |
| 330 | t, |
| 331 | ) |
| 332 | |
| 333 | return m, infosMap, handlerMap |
| 334 | } |
| 335 | |
| 336 | // Expect a manager with the specified containers and query. Returns the manager, map of ContainerInfo objects, |
| 337 | // and map of MockContainerHandler objects.} |
no test coverage detected
searching dependent graphs…