(t *testing.T)
| 34 | const testProject = "testProject" |
| 35 | |
| 36 | func TestKillAll(t *testing.T) { |
| 37 | mockCtrl := gomock.NewController(t) |
| 38 | defer mockCtrl.Finish() |
| 39 | |
| 40 | api, cli := prepareMocks(mockCtrl) |
| 41 | tested, err := NewComposeService(cli) |
| 42 | assert.NilError(t, err) |
| 43 | |
| 44 | name := strings.ToLower(testProject) |
| 45 | |
| 46 | api.EXPECT().ContainerList(t.Context(), client.ContainerListOptions{ |
| 47 | Filters: projectFilter(name).Add("label", compose.ConfigHashLabel), |
| 48 | }).Return(client.ContainerListResult{ |
| 49 | Items: []container.Summary{ |
| 50 | testContainer("service1", "123", false), |
| 51 | testContainer("service1", "456", false), |
| 52 | testContainer("service2", "789", false), |
| 53 | }, |
| 54 | }, nil) |
| 55 | api.EXPECT().VolumeList( |
| 56 | gomock.Any(), |
| 57 | client.VolumeListOptions{ |
| 58 | Filters: projectFilter(strings.ToLower(testProject)), |
| 59 | }). |
| 60 | Return(client.VolumeListResult{}, nil) |
| 61 | api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: projectFilter(strings.ToLower(testProject))}). |
| 62 | Return(client.NetworkListResult{ |
| 63 | Items: []network.Summary{{ |
| 64 | Network: network.Network{ID: "abc123", Name: "testProject_default"}, |
| 65 | }}, |
| 66 | }, nil) |
| 67 | api.EXPECT().ContainerKill(anyCancellableContext(), "123", client.ContainerKillOptions{}).Return(client.ContainerKillResult{}, nil) |
| 68 | api.EXPECT().ContainerKill(anyCancellableContext(), "456", client.ContainerKillOptions{}).Return(client.ContainerKillResult{}, nil) |
| 69 | api.EXPECT().ContainerKill(anyCancellableContext(), "789", client.ContainerKillOptions{}).Return(client.ContainerKillResult{}, nil) |
| 70 | |
| 71 | err = tested.Kill(t.Context(), name, compose.KillOptions{}) |
| 72 | assert.NilError(t, err) |
| 73 | } |
| 74 | |
| 75 | func TestKillSignal(t *testing.T) { |
| 76 | const serviceName = "service1" |
nothing calls this directly
no test coverage detected