(t *testing.T)
| 372 | } |
| 373 | |
| 374 | func TestDownRemoveImages_NoLabel(t *testing.T) { |
| 375 | mockCtrl := gomock.NewController(t) |
| 376 | defer mockCtrl.Finish() |
| 377 | |
| 378 | api, cli := prepareMocks(mockCtrl) |
| 379 | tested, err := NewComposeService(cli) |
| 380 | assert.NilError(t, err) |
| 381 | |
| 382 | ctr := testContainer("service1", "123", false) |
| 383 | |
| 384 | api.EXPECT().ContainerList(gomock.Any(), projectFilterListOpt(false)).Return( |
| 385 | client.ContainerListResult{ |
| 386 | Items: []container.Summary{ctr}, |
| 387 | }, nil) |
| 388 | |
| 389 | api.EXPECT().VolumeList( |
| 390 | gomock.Any(), |
| 391 | client.VolumeListOptions{ |
| 392 | Filters: projectFilter(strings.ToLower(testProject)), |
| 393 | }). |
| 394 | Return(client.VolumeListResult{ |
| 395 | Items: []volume.Volume{{Name: "myProject_volume"}}, |
| 396 | }, nil) |
| 397 | api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: projectFilter(strings.ToLower(testProject))}). |
| 398 | Return(client.NetworkListResult{}, nil) |
| 399 | |
| 400 | // ImageList returns no images for the project since they were unlabeled |
| 401 | // (created by an older version of Compose) |
| 402 | api.EXPECT().ImageList(gomock.Any(), client.ImageListOptions{ |
| 403 | Filters: projectFilter(strings.ToLower(testProject)).Add("dangling", "false"), |
| 404 | }).Return(client.ImageListResult{}, nil) |
| 405 | |
| 406 | api.EXPECT().ImageInspect(gomock.Any(), "testproject-service1", gomock.Any()).Return(client.ImageInspectResult{}, nil) |
| 407 | api.EXPECT().ContainerStop(gomock.Any(), "123", client.ContainerStopOptions{}).Return(client.ContainerStopResult{}, nil) |
| 408 | api.EXPECT().ContainerRemove(gomock.Any(), "123", client.ContainerRemoveOptions{Force: true}).Return(client.ContainerRemoveResult{}, nil) |
| 409 | |
| 410 | api.EXPECT().ImageRemove(gomock.Any(), "testproject-service1:latest", client.ImageRemoveOptions{}).Return(client.ImageRemoveResult{}, nil) |
| 411 | |
| 412 | err = tested.Down(t.Context(), strings.ToLower(testProject), compose.DownOptions{Images: "local"}) |
| 413 | assert.NilError(t, err) |
| 414 | } |
| 415 | |
| 416 | func prepareMocks(mockCtrl *gomock.Controller) (*mocks.MockAPIClient, *mocks.MockCli) { |
| 417 | api := mocks.NewMockAPIClient(mockCtrl) |
nothing calls this directly
no test coverage detected