(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestDownRemoveImages(t *testing.T) { |
| 274 | mockCtrl := gomock.NewController(t) |
| 275 | defer mockCtrl.Finish() |
| 276 | |
| 277 | opts := compose.DownOptions{ |
| 278 | Project: &types.Project{ |
| 279 | Name: strings.ToLower(testProject), |
| 280 | Services: types.Services{ |
| 281 | "local-anonymous": {Name: "local-anonymous"}, |
| 282 | "local-named": {Name: "local-named", Image: "local-named-image"}, |
| 283 | "remote": {Name: "remote", Image: "remote-image"}, |
| 284 | "remote-tagged": {Name: "remote-tagged", Image: "registry.example.com/remote-image-tagged:v1.0"}, |
| 285 | "no-images-anonymous": {Name: "no-images-anonymous"}, |
| 286 | "no-images-named": {Name: "no-images-named", Image: "missing-named-image"}, |
| 287 | }, |
| 288 | }, |
| 289 | } |
| 290 | |
| 291 | api, cli := prepareMocks(mockCtrl) |
| 292 | tested, err := NewComposeService(cli) |
| 293 | assert.NilError(t, err) |
| 294 | |
| 295 | api.EXPECT().ContainerList(gomock.Any(), projectFilterListOpt(false)). |
| 296 | Return(client.ContainerListResult{ |
| 297 | Items: []container.Summary{ |
| 298 | testContainer("service1", "123", false), |
| 299 | }, |
| 300 | }, nil). |
| 301 | AnyTimes() |
| 302 | |
| 303 | api.EXPECT().ImageList(gomock.Any(), client.ImageListOptions{ |
| 304 | Filters: projectFilter(strings.ToLower(testProject)).Add("dangling", "false"), |
| 305 | }).Return(client.ImageListResult{Items: []image.Summary{ |
| 306 | { |
| 307 | Labels: types.Labels{compose.ServiceLabel: "local-anonymous"}, |
| 308 | RepoTags: []string{"testproject-local-anonymous:latest"}, |
| 309 | }, |
| 310 | { |
| 311 | Labels: types.Labels{compose.ServiceLabel: "local-named"}, |
| 312 | RepoTags: []string{"local-named-image:latest"}, |
| 313 | }, |
| 314 | }}, nil).AnyTimes() |
| 315 | |
| 316 | imagesToBeInspected := map[string]bool{ |
| 317 | "testproject-local-anonymous": true, |
| 318 | "local-named-image": true, |
| 319 | "remote-image": true, |
| 320 | "testproject-no-images-anonymous": false, |
| 321 | "missing-named-image": false, |
| 322 | } |
| 323 | for img, exists := range imagesToBeInspected { |
| 324 | var resp image.InspectResponse |
| 325 | var err error |
| 326 | if exists { |
| 327 | resp.RepoTags = []string{img} |
| 328 | } else { |
| 329 | err = errdefs.ErrNotFound.WithMessage(fmt.Sprintf("test specified that image %q should not exist", img)) |
| 330 | } |
nothing calls this directly
no test coverage detected